read method
The bytes whose SHA-256 is sha256, checked again; null when missing,
damaged (a damaged copy is deleted), or busy in another process.
Throws ArgumentError unless sha256 is 64 lowercase hex digits.
Implementation
Uint8List? read(String sha256) {
final file = fileFor(sha256);
try {
if (!file.existsSync()) return null;
final bytes = file.readAsBytesSync();
if (Sha256.hexOf(bytes) == sha256) return bytes;
file.deleteSync();
} on FileSystemException {
// Another process is replacing it, or it can't be read: a miss.
}
return null;
}