Use CompressionMethod.Stored and flush the ZipOutputStream after each entity was added leads Zip corrupted in SharpZipLib 1.4.2
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với cách xử lý ZipOutputStream và ZipEntry được thể hiện trong báo cáo, tập trung vào việc đóng entry bất đồng bộ và FlushAsync khi sử dụng CompressionMethod.Stored. Tái hiện chuỗi này với nhiều tệp, sau đó xác minh rằng việc flush sau mỗi entity được thêm vào vẫn tạo ra một archive hợp lệ chứa mọi tệp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- C#
- Star
- 3.9k
- Fork
- 1k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của icsharpcode/SharpZipLib
-
*no response* bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
icsharpcode/SharpZipLib#905 · 1 bình luận ·
-
bug bzip2
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
icsharpcode/SharpZipLib#904 ·
-
SetLevel in ZipFile Đang mởenhancement zip
Độ khó 2/5 1-2 ngày Mức phù hợp với người mới 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
icsharpcode/SharpZipLib#901 · 1 bình luận ·
-
*no response* bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
icsharpcode/SharpZipLib#894 · 1 bình luận ·
Tất cả issue của icsharpcode/SharpZipLib
Issue tương tự
-
CS0162 "Unreachable code detected" warning from a MSBuildTemp .tmp file in every game project Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Type: enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
apache/arrow-adbc#4809 ·
-
type/automation type/tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
microsoft/vscode-azurefunctions#5197 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
microsoft/microsoft-ui-reactor#1274 ·