Playtest: checksum test files in pieces, for whole episodes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -129,5 +129,10 @@ class PlaytestFileActivity : Activity() {
|
||||
|
||||
override fun onStop() { super.onStop(); if (!finished) { result.put("outcome", "left early"); end() } }
|
||||
|
||||
private fun sha256(f: File) = MessageDigest.getInstance("SHA-256").digest(f.readBytes()).joinToString("") { "%02x".format(it) }
|
||||
// Read in pieces (23 November 2026): a whole episode is hundreds of megabytes, too much to hold in memory at once.
|
||||
private fun sha256(f: File): String = f.inputStream().use { input ->
|
||||
val digest = MessageDigest.getInstance("SHA-256"); val buffer = ByteArray(1 shl 20)
|
||||
while (true) { val n = input.read(buffer); if (n < 0) break; digest.update(buffer, 0, n) }
|
||||
digest.digest().joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user