Skip to content

Commit

Permalink
Fix #3038 (Hash validation crash) (#3142)
Browse files Browse the repository at this point in the history
  • Loading branch information
superblaubeere27 authored May 27, 2024
1 parent f9662a0 commit 84e403f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ object HashValidator {
}

private fun validateHashFile(hashFile: File) {
val hashes: (FileInputStream) -> Map<String, String> = {
val hashExtractor: (FileInputStream) -> Map<String, String> = {
Gson().fromJson(
InputStreamReader(it),
object : TypeToken<Map<String, String>>() {}.type
)
}

val delete = shouldDelete(hashFile, FileInputStream(hashFile).use(hashes))
val delete = runCatching {
val hashes = FileInputStream(hashFile).use(hashExtractor)

shouldDelete(hashFile, hashes)
}.onFailure {
logger.warn("Invalid hash file ${hashFile.absolutePath}", it)
}.getOrDefault(true)

if (delete) {
val folderToDelete = hashFile.parentFile
Expand Down

0 comments on commit 84e403f

Please sign in to comment.