-
Notifications
You must be signed in to change notification settings - Fork 49
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
Unexpected result when comparing file content in and out of zip #172
Comments
@mtkennerly thanks for the issue. Could you please try to load whole into the memory instead of using buffering? Previously we had the same issue with buffering. I guess it could be somehow related to it. |
Looks like you're right: Diffdiff --git a/src/main.rs b/src/main.rs
index 1a8dc9c..249cc3d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,8 +16,8 @@ fn try_same_content_as_zip(original: &str, archived: &mut ZipFile) -> Result<boo
let handle = File::open(original)?;
let mut reader = BufReader::new(handle);
- let mut disk_buffer = [0; 1024];
- let mut zip_buffer = [0; 1024];
+ let mut disk_buffer = vec![];
+ let mut zip_buffer = vec![];
loop {
let read_disk = reader.read(&mut disk_buffer[..])?;
let read_zip = archived.read(&mut zip_buffer[..])?; Output
|
@mtkennerly Fortunately (or unfortunately) I was right... What I could propose to you. If you are really interested in the library, try to debug More lazy way - just don't use buffering :) |
That's fair! I took a very brief look, and I wonder if it might be an issue in |
Yikes, this is bad. And it's probably our fault tbh. Thankyou for the reproducible case, I'll try to hunt this down! |
i confirm i have the same issue, zipping up csv files end up with mangled files, it seems like sometimes some bytes are removed (i guess the exact size of the buffer) and i end up with a few lines missing data/eating up the new line: 2023-03-04 00:16:00,0.2302,0.2302,0.23,0.2301,45967 this is my code:
i confirm this doesn't seem to be happening with sevenz_rust nor flate2-rs. |
Hi! I may have missed or misunderstood something from the documentation, but I just ran into this and found it surprising.
I have a backup utility, and I want to check the previous backup archive to see if the content is the same as the latest scan. It works for some files, but not others, and I'm not sure why. I've created a minimal example of the issue: https://gist.github.com/mtkennerly/981622694bb9313253a91ea8e4ebde9d
Output:
I'm not sure why screenshot.jpg doesn't compare equal. It works if I change
CompressionMethod::Deflated
toCompressionMethod::Stored
orCompressionMethod::Bzip2
, whereas it has the same issue if I useCompressionMethod::Zstd
. How could I accomplish what I'm trying to do?I'm using a buffered read of 1 KiB at a time since the actual files may be too large to load into memory. I also considered comparing CRC hashes with
ZipFile::crc32
, but I wasn't sure how to compute a compatible hash for an unarchived file, since there seem to be a lot of different CRC variations.I'm using Windows 11, Rust 1.63.0, and Zip 0.6.2.
Assets
Place these in an
assets
folder next tosrc
:The text was updated successfully, but these errors were encountered: