MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / assetsFileChecksum

Function assetsFileChecksum

app/build.gradle.kts:1240–1269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1238}
1239
1240fun assetsFileChecksum(asset: Asset): String? {
1241 return if (isCiCd) {
1242 val stagedChecksum = stagedChecksumFor(asset, rootProject.projectDir)
1243 if (stagedChecksum.exists()) {
1244 stagedChecksum.readText().trim()
1245 } else {
1246 throw GradleException("Failed to find checksum in ${stagedChecksum.absolutePath}")
1247 }
1248 } else {
1249 val checksumUrl = asset.url + ".md5"
1250 val conn = URL(checksumUrl).openConnection() as HttpURLConnection
1251 conn.requestMethod = "GET"
1252 conn.setRequestProperty("User-Agent", "Mozilla/5.0")
1253 conn.instanceFollowRedirects = true
1254 conn.connectTimeout = 10_000
1255 conn.readTimeout = 10_000
1256
1257 return try {
1258 val status = conn.responseCode
1259
1260 if (status == HttpURLConnection.HTTP_OK) {
1261 conn.inputStream.bufferedReader().use { it.readText().trim() }
1262 } else {
1263 throw GradleException("Failed to fetch checksum from $checksumUrl (HTTP $status: ${conn.responseMessage})")
1264 }
1265 } finally {
1266 conn.disconnect()
1267 }
1268 }
1269}
1270
1271fun assetsDownload(
1272 assets: List<Asset>,

Callers 1

assetsDownloadFunction · 0.85

Calls 5

stagedChecksumForFunction · 0.85
openConnectionMethod · 0.80
disconnectMethod · 0.80
trimMethod · 0.65
existsMethod · 0.45

Tested by

no test coverage detected