Use CompressionMethod.Stored and flush the ZipOutputStream after each entity was added leads Zip corrupted in SharpZipLib 1.4.2
まだ誰も着手していません。
評価
調査の方向性
レポートに示されている ZipOutputStream と ZipEntry の処理から始め、CompressionMethod.Stored を使用する場合のエントリの非同期クローズと FlushAsync に焦点を当てます。複数のファイルでこのシーケンスを再現し、その後、追加した各エンティティの後にフラッシュしても、すべてのファイルを含む有効なアーカイブが生成されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
I found a bug that if I set CompressionMethod = CompressionMethod.Stored in the entry and flush the ZipOutputStream, the output zip is corrupted and only the first file exists in the zip file.
using (Stream NewZipStream = File.OpenWrite(Path.GetRandomFileName()))
using (ZipOutputStream ZipStream = new ZipOutputStream(NewZipStream , StringCodec.FromEncoding(Encoding.UTF8)))
{
ZipStream.SetLevel(0);
ZipStream.UseZip64 = UseZip64.Dynamic;
ZipStream.IsStreamOwner = false;
foreach (string FilePath in Directory.EnumerateFiles("<Your folder that has multiple files>"))
{
using (Stream FileStream = File.OpenRead(FilePath))
{
ZipEntry NewEntry = new ZipEntry(File.Name)
{
DateTime = DateTime.Now,
CompressionMethod = CompressionMethod.Stored,
Size = FileStream.Length
};
await ZipStream.PutNextEntryAsync(NewEntry, CancelToken);
await FileStream.CopyToAsync(ZipStream);
await ZipStream.CloseEntryAsync(CancelToken);
}
await ZipStream.FlushAsync(CancelToken);
}
}
Reproduction Code
No response
Steps to reproduce
- Use ZipOutputStream
- Set CompressionMethod to CompressionMethod.Stored on ZipEntry
- Add multiple files/folders into ZipOutputStream
- Flush the ZipOutputStream once each entity was added
- Found the zip file is corrupted
Expected behavior
Zip is not corrupted
Operating System
Windows
Framework Version
.NET 7
Tags
ZIP
Additional context
No response
- 主要言語
- C#
- スター
- 3.9k
- フォーク
- 1k
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
icsharpcode/SharpZipLib のほかの issue
-
*no response* bug
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
icsharpcode/SharpZipLib#905 · コメント 1 件 ·
-
bug bzip2
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
icsharpcode/SharpZipLib#904 ·
-
SetLevel in ZipFile オープンenhancement zip
難易度 2/5 1〜2日 初心者へのやさしさ 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
icsharpcode/SharpZipLib#901 · コメント 1 件 ·
-
*no response* bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
icsharpcode/SharpZipLib#894 · コメント 1 件 ·
icsharpcode/SharpZipLib の issue をすべて見る
似ている issue
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
apache/arrow-adbc#4809 ·
-
type/automation type/tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
microsoft/vscode-azurefunctions#5197 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
microsoft/microsoft-ui-reactor#1274 ·