Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions app/lib/package/tarball_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ class TarballStorage {
return ContentMatchStatus.different;
}
// Limit memory use while doing the byte-to-byte comparison by streaming it chunk-wise.
final raf = await file.open();
var remainingLength = info.length;
try {
await _canonicalBucket.readWithRetry(objectName, (input) async {
var remainingLength = -1;
await _canonicalBucket.readWithRetry(objectName, (input) async {
final raf = await file.open();
remainingLength = info.length;
try {
await for (final chunk in input) {
if (chunk.isEmpty) continue;
remainingLength -= chunk.length;
Expand All @@ -131,10 +132,10 @@ class TarballStorage {
return ContentMatchStatus.different;
}
}
});
} finally {
await raf.close();
}
} finally {
await raf.close();
}
});
if (remainingLength != 0) {
return ContentMatchStatus.different;
}
Expand Down