Skip to content

Commit

Permalink
refactor(gradle-inspector): Simplify check for zero byte artifacts
Browse files Browse the repository at this point in the history
Replace the combination of `takeUnless` and `run` with a simple `if` to
improve readability.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher authored and sschuberth committed Feb 19, 2024
1 parent 44fc219 commit efc2310
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,13 @@ private fun GradleInspector.createRemoteArtifact(
val checksum = okHttpClient.downloadText("$artifactUrl.$algorithm")
.getOrElse { return RemoteArtifact.EMPTY }

val hash = parseChecksum(checksum, algorithm)

// Ignore file with zero byte size, because it cannot be a valid archive.
val hash = parseChecksum(checksum, algorithm).takeUnless { it.value == ZERO_BYTES_FILE_SHA1 }
?: run {
logger.info("Ignoring zero byte size artifact: $artifactUrl.")
return RemoteArtifact.EMPTY
}
if (hash.value == ZERO_BYTES_FILE_SHA1) {
logger.info("Ignoring zero byte size artifact: $artifactUrl.")
return RemoteArtifact.EMPTY
}

return RemoteArtifact(artifactUrl, hash)
}
Expand Down

0 comments on commit efc2310

Please sign in to comment.