mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Tar corruption when writing active files #619
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lopio on GitHub (Mar 28, 2024).
I use the library to compress logs in a streaming manner, without saving a temporary file or storing to memory (RAM and diskspace restriction).
When I use the tar writer to archive active files (logs) the size of the tar header doesn't match the file in the tar, because the file has increased in size between the time the header was created and the file was fully read.
This result in the tar entry being corrupted, and sometime it can also result in the file in question not being recoverable.
Repro steps: Create a tar archive with a file that is being written in actively.
The fix is to stop reading the file at the size set by the tar header. Attached is the proposed fix as a git patch
tarCorruption.patch
@adamhathcock commented on GitHub (Mar 29, 2024):
I seemingly can't use that patch file
Any chance of a PR?
@lopio commented on GitHub (Mar 29, 2024):
I can't find a way to create a branch for the PR. I do have my complete git diff here:
@lopio commented on GitHub (Apr 8, 2024):
Fixed tarCorruption.patch
@adamhathcock commented on GitHub (Apr 9, 2024):
modified the patch a little as my client corrupted it I think
Please validate the PR