DownloadWorker, really fail on incorrect hashes

assert() only does something in debug builds, so the hash was never really checked.

The Log.e line might be reduntant.
This commit is contained in:
ggabr
2024-07-27 15:07:24 +02:00
parent 5dc790d750
commit 5ffb6b3886

View File

@@ -298,8 +298,13 @@ class DownloadWorker @AssistedInject constructor(
}
// Ensure downloaded file matches expected sha
assert(validSha(request.file, expectedSha, algorithm))
return@withContext Result.success()
if (validSha(request.file, expectedSha, algorithm)) {
return@withContext Result.success()
} else {
Log.e(TAG, "Incorrect hash for ${request.file}")
throw Exception("Incorrect hash")
}
} catch (exception: Exception) {
Log.e(TAG, "Failed to download ${request.file}!", exception)
notifyStatus(DownloadStatus.FAILED)