Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`WriteEntry(TarEntry, bool)` writes the entry without bytes if the file is used by another process

Đang mở
#819 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu trong src/ICSharpCode.SharpZipLib/Tar/TarArchive.cs tại các dòng được liên kết xung quanh WriteEntry(TarEntry, bool), đặc biệt là nơi entry được thêm vào và nơi việc đọc tệp phát sinh IOException. Theo dõi cách một lần đọc thất bại đi đến quá trình giải phóng archive và xem xét các test hiện có liên quan đến Tar. Hoàn thành khi một tệp bị khóa tạo ra lỗi có ngữ cảnh rõ ràng mà không để lại entry mồ côi gây ra TarException về sau.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug tar
Describe the bug

This issue makes it inconvenient to use SharpZipLib, because disposing the tar archive will throw a TarException that hides the underlying issue. When a file is used by another process, WriteEntry(TarEntry, bool) writes the entry, but obviously not the bytes (which is fine). Due to the dangling tar entry, disposing (leaving the using block) the tar archive throws:

Entry closed at '0' before the 'x' bytes specified in the header were written.

It is not clear which file is responsible for the error. Following line throws an IOException:

https://github.com/icsharpcode/SharpZipLib/blob/c51ef18c55988e3251b15f038ced1d9064b6da2f/src/ICSharpCode.SharpZipLib/Tar/TarArchive.cs#L891

if a file is used by another process, but a few lines before, the entry is already added:

https://github.com/icsharpcode/SharpZipLib/blob/c51ef18c55988e3251b15f038ced1d9064b6da2f/src/ICSharpCode.SharpZipLib/Tar/TarArchive.cs#L876

Reproduction Code

No response

Steps to reproduce

-

Expected behavior

WriteEntry(TarEntry, bool) fails with a clear error message that considers the context.

Operating System

Windows, macOS, Linux

Framework Version

.NET 7, .NET 6

Tags

Tar

Additional context

As workaround I check in advance if the process can read the file.

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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của icsharpcode/SharpZipLib

Tất cả issue của icsharpcode/SharpZipLib

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.