-
Notifications
You must be signed in to change notification settings - Fork 97
addData requires that data remains valid until close #152
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
Comments
I found a workaround, adding |
Hi @flomnes, Unfortunately it is how the underlying |
@ctabin The problem is that in order to keep a valid archive, when adding data to an existing archive libzip creates a copy, writes to that copy and replaces the original. It operates that way to ensure that in case of error, the original will not be corrupted. If the original is 5Gb and you want to add a few files, it becomes very expensive in terms of disk I/O. I haven't found a way to disable it. On the other hand, minizip-ng seems to write files immediately to the existing archive. |
@flomnes I met this same problem in my work, where total size may reach 10 GB making the fake flush unaccecpable. A possible workaround I adapted is writing that data to a temp file on disk, then call the |
I also got burnt on this. My suggestion to solve this is to add a method that takes the data either as Something like: using BinString = std::basic_string<uint8_t>;
bool addData(const std::string& entryName,
std::shared_ptr<BinString> data); |
Short description
When adding some data through
ZipArchive::addData
, the buffer read/file write is delayed untilZipArchive::close
is called. This is a problem if the user wants to write the data immediately and free the underlying memory.I couldn't find any workaround.
Example from my project
The text was updated successfully, but these errors were encountered: