dyz1990 / sevenz-rust

A 7z decompressor/compressor lib written in pure rust
Apache License 2.0
153 stars 24 forks source link

Change push_archive_entry to return archive entry. #9

Closed nlfiedler closed 1 year ago

nlfiedler commented 1 year ago

When writing archive entries with sevenz, I would very much like to get the compressed size of each entry after it is written. However, the SevenZWriter.push_archive_entry() takes the entry from the caller and never returns it. I believe that the function should either take a mutable reference or return the modified entry back to the caller. As it stands now, the function is updating the entry fields but then the entry is dropped. If making this change is agreeable, I would be happy to submit a PR.

dyz1990 commented 1 year ago

@nlfiedler I fully agree with your suggestion. And I'm looking forward your PR. BTW, the entry was pushed into the files Vec, it was not dropped. So your should use self.files.last().unwrap() to return the entry's reference.

nlfiedler commented 1 year ago

Great, and thank you for the proposed solution, it makes for a very easy change.

Fixed in 606ad04e387a97810f7ae99d6d5839dc946c0a75