Skip to content

Commit

Permalink
fix maven download logic
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkyAI committed Mar 13, 2021
1 parent bf181d6 commit af340b6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 56 deletions.
47 changes: 0 additions & 47 deletions .github/workflows/PUSH.yml

This file was deleted.

3 changes: 1 addition & 2 deletions util/maven/src/main/kotlin/voodoo.util/maven/MavenUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ object MavenUtil : KLogging() {

val artifactUrl = "$mavenUrl/$groupPath/$artifactId/$version/$artifactId-$version$classifierSuffix.$extension"
logger.trace { "downloading: $artifactUrl" }
val tmpFile = File(outputDir, "$artifactId-$version$classifierSuffix.$extension.tmp")
val targetFile = outputFile ?: File(outputDir, "$artifactId-$version$classifierSuffix.$extension")
targetFile.absoluteFile.parentFile.mkdirs()
targetFile.download(
Expand All @@ -113,7 +112,7 @@ object MavenUtil : KLogging() {
}
}

val fileSha1 = MessageDigest.getInstance("SHA-1").digest(tmpFile.readBytes()).toHexString()
val fileSha1 = MessageDigest.getInstance("SHA-1").digest(bytes).toHexString()
// require(fileSha1 == sha1) { "$artifactUrl did not match SHA-1 hash: '$sha1'" }
fileSha1 == sha1
} else {
Expand Down
9 changes: 2 additions & 7 deletions voodoo/src/main/kotlin/voodoo/cli/UpdateCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import mu.withLoggingContext
import voodoo.util.Directories
import voodoo.util.download
import voodoo.util.maven.MavenUtil
import voodoo.util.toHexString
import voodoo.util.useClient
import voodoo.voodoo.GeneratedConstants
import java.io.File
Expand Down Expand Up @@ -57,7 +58,7 @@ class UpdateCommand : CliktCommand(
tmpFile.download(distributionUrl, cacheDir = cacheHome)
useClient { client ->
val md5 = client.get<String>(distributionUrl + ".md5")
val fileMd5 = hex(createMD5(tmpFile))
val fileMd5 = createMD5(tmpFile).toHexString()
require(fileMd5 == md5) { "checksum file ${distributionUrl}.md5 does not match the actual checksum of $distributionUrl" }
}

Expand All @@ -71,12 +72,6 @@ class UpdateCommand : CliktCommand(
}
}

private fun toHexString(bytes: ByteArray): String {
return buildString {
bytes.forEach { b -> append(String.format("%02x", b)) }
}
}

@Throws(Exception::class)
fun createMD5(file: File): ByteArray {
return file.inputStream().use { fis ->
Expand Down

0 comments on commit af340b6

Please sign in to comment.