Skip to content

return Stream.Null when 7z entry has no stream#854

Merged
adamhathcock merged 2 commits intoadamhathcock:masterfrom
zgabi:patch-1
Apr 28, 2025
Merged

return Stream.Null when 7z entry has no stream#854
adamhathcock merged 2 commits intoadamhathcock:masterfrom
zgabi:patch-1

Conversation

@zgabi
Copy link
Contributor

@zgabi zgabi commented Jul 6, 2024

bug: 7z file extraction fails when the archive contains empty file

I'm using the following code to extract a 7z file:

using var sevenZip = SharpCompress.Archives.SevenZip.SevenZipArchive.Open(data);
sevenZip.WriteToDirectory(root);

But it fails when the archive file (data) contains an empy file.
The same GetCompressedStream method returns Stream.Null, I think this method should also return Stream.Null instead throwing an exception.

It would be good to put an empy file to the tests\TestArchives\Original folder and to all the test files, to cover this case in the tests, but I don't know how to create them.

@adamhathcock
Copy link
Owner

There should be a tested added but can merge just for consistency

@zgabi
Copy link
Contributor Author

zgabi commented Jul 9, 2024

Yes. There should be an empty file in the tests\TestArchives\Original folder... but I don't know how to add that to all "exotic" archives in the tests\TestArchives\Archives folder (for example tests\TestArchives\Archives\7Zip.ZSTD.7z). So please add it. Thank you.

@adamhathcock adamhathcock enabled auto-merge April 28, 2025 15:23
@adamhathcock adamhathcock merged commit 2c45220 into adamhathcock:master Apr 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants