`ArchiveFile.rawContent` is null when decoded from an Archive
Closed this issue · 6 comments
This test passes on 3.3.2 but fails on >=3.3.3:
final Archive archive = Archive()
..addFile(ArchiveFile('AndroidManifest.xml', 100, List<int>.filled(100, 0)));
final File apk = fileSystem.file('test.apk')
..writeAsBytesSync(ZipEncoder().encode(archive)!);
final Archive decodedArchive = ZipDecoder().decodeBytes(apk.readAsBytesSync());
for (final ArchiveFile archiveFile in decodedArchive.files) {
expect(archiveFile.rawContent, isNotNull);
expect(archiveFile.rawContent!.length, 6);
}
During decodeBytes
zf
is a ZipFile
.
archive/lib/src/zip_decoder.dart
Lines 42 to 43 in 98e1158
Which is a FileContent
, and _rawContent
is not set. Which means the decoded ArchiveFile.rawContent
is unexpectedly null.
archive/lib/src/archive_file.dart
Lines 84 to 86 in 98e1158
I would instead expect the ArchiveFile.rawContent
at this point to be the same as the ZipFile.rawContent
:
archive/lib/src/zip/zip_file.dart
Lines 183 to 188 in 98e1158
Looks like it was caused around 3dd6a05
Context is I'm trying to bump the Flutter command line tool from 3.3.2 to >=3.5.0, higher than the security advisory fixes, and past when pointycastle
was removed flutter/flutter#149427 (comment). I'm open to suggestions for workarounds:
https://github.com/flutter/flutter/blob/3bc1f517c0365ab1dcdbfb6378dfa7481148b8da/packages/flutter_tools/lib/src/base/analyze_size.dart#L154-L161
Thanks for the report, I'll get whatever is going wrong fixed.
I am working on a 4.0 branch, I'll make sure whatever gets fixed is applied to that too.
I pushed a fix to the main branch. I'll work on a release publish shortly.
Thanks for the quick response!
Published to 3.6.1. I added a test based on your example, so I'm assuming it's good now.
Published to 3.6.1. I added a test based on your example, so I'm assuming it's good now.
It worked, thank you! Feel free to close.