-
Notifications
You must be signed in to change notification settings - Fork 976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WriteEntry(TarEntry, bool)
writes the entry without bytes if the file is used by another process
#819
Comments
That doesn't seem right. If the file is locked, it should throw an IO error when adding it. We don't have anything that catches such an error and proceeds without writing. Perhaps whatever is using the file truncates it (setting the size to 0)? |
It throws an
SharpZipLib/src/ICSharpCode.SharpZipLib/Tar/TarOutputStream.cs Lines 398 to 404 in c51ef18
|
What |
I think what you want is to be using |
I am referring to the TarArchive instance.
Thanks, I will look into it.
I still think there is room for improvements. Even in the use case you mention here, the |
It should be possible to just move the |
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 theusing
block) the tar archive throws:It is not clear which file is responsible for the error. Following line throws an
IOException
:SharpZipLib/src/ICSharpCode.SharpZipLib/Tar/TarArchive.cs
Line 891 in c51ef18
if a file is used by another process, but a few lines before, the entry is already added:
SharpZipLib/src/ICSharpCode.SharpZipLib/Tar/TarArchive.cs
Line 876 in c51ef18
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.
The text was updated successfully, but these errors were encountered: