Closed Pr0methean closed 1 year ago
The workaround I used can be seen in its full context at https://github.com/Pr0methean/OcHd-RustBuild/blob/010f5049fc216532598e1cd56041a065e74b76b6/main/src/image_tasks/png_output.rs#L47
I've created a fork at https://crates.io/crates/zip_next that adds this feature and uses only safe code. It makes a shallow copy (i.e. updates only the central directory).
Also implemented a deep copy in 0.6.7, provided the underlying storage implements Read.
Yeah, definitely don't use the unsafe code above :) that's entirely unsound. Awesome job making this API in zip_next! It's a nice optimization. I don't think I'm going bring the API into this crate as-is, but I'll be keeping this usecase in mind
My app needs to duplicate some compressed files after the originals have been written to the
Cursor<Vec<u8>>
that eventually becomes the ZIP file, and the uncompressed originals have been dropped. The only way I've been able to find to accomplish that without a decompression round-trip is (whereZIP
is aMutex<ZipWriter<Cursor<Vec<u8>>>>
, the function return type isResult<(),CloneableError>
andanyhoo!
is a macro similar toanyhow!
but that produces aCloneableError
):This could probably be made much more efficient with a method dedicated to the same-zip-file case, which would shallow-copy the file entry so that the same copy of its compressed contents would be written twice.