diff --git a/model/src/main/kotlin/Hash.kt b/model/src/main/kotlin/Hash.kt index 4f5b6df55b2d2..e8221f3146d3b 100644 --- a/model/src/main/kotlin/Hash.kt +++ b/model/src/main/kotlin/Hash.kt @@ -78,6 +78,11 @@ data class Hash( "'$value' is not a $algorithm hash." } } + + /** + * Create a [Hash] instance similar to [create](String,String). + */ + fun create(value: String, algorithm: HashAlgorithm): Hash = create(value, algorithm.name) } /** diff --git a/plugins/package-managers/conan/src/main/kotlin/Conan.kt b/plugins/package-managers/conan/src/main/kotlin/Conan.kt index 09800f73b4186..0e3984390e4db 100644 --- a/plugins/package-managers/conan/src/main/kotlin/Conan.kt +++ b/plugins/package-managers/conan/src/main/kotlin/Conan.kt @@ -395,7 +395,7 @@ class Conan( (urlNode.takeIf { it.isTextual } ?: urlNode.first()).textValueOrEmpty() } - val hash = Hash.create(artifactEntry["sha256"].textValueOrEmpty(), HashAlgorithm.SHA256.name) + val hash = Hash.create(artifactEntry["sha256"].textValueOrEmpty(), HashAlgorithm.SHA256) RemoteArtifact(url, hash) }.getOrElse { diff --git a/plugins/package-managers/pub/src/main/kotlin/Pub.kt b/plugins/package-managers/pub/src/main/kotlin/Pub.kt index 83530a7c2987d..fb5c0df15ea38 100644 --- a/plugins/package-managers/pub/src/main/kotlin/Pub.kt +++ b/plugins/package-managers/pub/src/main/kotlin/Pub.kt @@ -620,7 +620,7 @@ class Pub( RemoteArtifact( url = "$hostUrl/packages/$rawName/versions/$version.tar.gz", - hash = Hash.create(sha256, HashAlgorithm.SHA256.name) + hash = Hash.create(sha256, HashAlgorithm.SHA256) ) } else { RemoteArtifact.EMPTY