You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the noop unzip held the whole backup in memory. _inflateMember now streams the raw deflate straight to the file, crc check after it is unchanged. falls back to the old path for encrypted/unknown-method members.
touches the same function as #1032. no memory test: peak rss can't be asserted in flutter test, existing import tests cover the stale-size and bad-crc cases.
Summary by CodeRabbit
Bug Fixes
Improved archive imports for stored and deflated ZIP files, with fallback handling for encrypted, unsupported, or malformed entries.
No actionable comments were generated in the recent review.
Walkthrough
The import path now streams unencrypted ZIP members with stored or deflate compression directly to disk. It validates the local header and uses raw zlib decoding for deflate. Encrypted members, unsupported compression methods, and invalid local headers use the existing writeContent fallback.
Changes: ZIP member streaming
Layer / File(s)
Summary
Stream supported ZIP members lib/import/import_container.dart
_inflateMember locates the indexed member and its metadata. It streams supported members to disk, uses raw zlib decoding for deflate, and retains writeContent as a fallback. The imports distinguish the dart:io decoder from the archive package decoder.
sequenceDiagram
participant InflateMember as _inflateMember
participant Archive
participant ZIPFile as ZIP file
participant ZLibDecoder
participant OutputFileStream
participant WriteContent as ArchiveFile.writeContent
InflateMember->>Archive: Decode archive and select indexed member
Archive-->>InflateMember: Return member metadata
alt Valid unencrypted deflate member
InflateMember->>ZIPFile: Read compressed byte range
ZIPFile->>ZLibDecoder: Send compressed bytes
ZLibDecoder->>OutputFileStream: Write decoded chunks
else Valid unencrypted stored member
InflateMember->>ZIPFile: Read stored byte range
ZIPFile->>OutputFileStream: Write member chunks
else Encrypted, unsupported, or invalid local header
InflateMember->>WriteContent: Use existing extraction fallback
end
Loading
Possibly related issues
Issue 1031: The PR streams extracted data to disk, addressing the memory aspect of large backup imports. The change does not establish that the reported 2 GB extraction limit is removed.
Merge Risk: Minimal · up to 00ec2
This change streams supported backup members to disk during import, which lowers peak memory use for large backups. The supplied evidence shows no concrete regression, and the fallback path covers the unsupported cases. Merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "noop import: stream the unzip to disk" matches the main change. The raw summary and PR objectives both say _inflateMember now streams unencrypted stored or deflated members directly to di…
Linked Issues check
[#1042] The issue asks to stop holding the inflated NOOP database in memory during import. The diff in lib/import/import_container.dart changes _inflateMember. For stored (method 0) or deflated (met…
Out of Scope Changes check
The whole-PR diff against the merge base changes one file, lib/import/import_container.dart. The changes are: a dart:io as io show ZLibDecoder import with hide ZLibDecoder on the archive import, w…
Full details: Title check
Explanation
The title "noop import: stream the unzip to disk" matches the main change. The raw summary and PR objectives both say _inflateMember now streams unencrypted stored or deflated members directly to disk instead of holding the backup in memory. The title names the import path and the streaming approach. It is specific and concise. It does not mention the fallback path, but that is a secondary detail.
Full details: Linked Issues check
Explanation
[#1042] The issue asks to stop holding the inflated NOOP database in memory during import. The diff in lib/import/import_container.dart changes _inflateMember. For stored (method 0) or deflated (method 8) members without the encryption flag, it reads the 30-byte local header, computes the data start offset, and streams the member through File(zipPath).openRead(start, start + compressedSize). For method 8 it applies ZLibDecoder(raw: true), then pipes the output to destPath. This matches the prototype approach in the issue. No size cap is applied, so the stale-size case is not rejected by the new path. Encrypted members, unknown compression methods, and invalid local headers fall back to the original OutputFileStream and writeContent path. The issue requires the stale-size behavior and bad-CRC rejection to be preserved. The diff does not change the caller's CRC check, and the PR states that the existing tests for these cases still apply. Those tests were not re-run in this review. The issue prototype computes CRC while streaming. This PR does not, so the CRC check still runs after extraction. This is a design difference, not a missing requirement. Peak memory was not measured; the issue reports prototype measurements only, and no app-level memory verification is required by the coding objectives.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base changes one file, lib/import/import_container.dart. The changes are: a dart:io as io show ZLibDecoder import with hide ZLibDecoder on the archive import, which avoids a name conflict for the raw decoder; the new streaming branch in _inflateMember; and the existing fallback to writeContent. All changes support the streaming objective in #1042. The PR adds no unrelated refactoring or behavior changes. The PR description notes that it touches the same function as #1032. That overlap is not a scope issue for this review.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Fix failing CI checks
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between fc6115e and 00ec2d3.
Files selected for processing: 1
lib/import/import_container.dart
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #1042
the noop unzip held the whole backup in memory.
_inflateMembernow streams the raw deflate straight to the file, crc check after it is unchanged. falls back to the old path for encrypted/unknown-method members.touches the same function as #1032. no memory test: peak rss can't be asserted in flutter test, existing import tests cover the stale-size and bad-crc cases.
Summary by CodeRabbit