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
Append/Insert files into an existing Zip file? #397
Comments
I don't think it's possible with the zip format, even the Tar is appendable because the format is basically just like delimiter-separated files, so you can easily add to it. Closing, but feel free to continue discussion if needed. |
@mholt I found this library which does exactly what I need. I found some github issues online where this was requested by the below developer to be included in OOTB golang but core devs pushed back saying there wasn't enough need for it but if the community really wanted it they could look at putting it in. |
Ah wow, I didn't know that was possible since even the official zip tooling doesn't support it. Looks complicated. I can see why it's not obvious... Let me see if I can get that library working with this one. |
Hmmm... I cannot get it to create a zip file that isn't corrupted (according to |
D'oh -- just kidding. I forgot to close the Updater. I have a commit that works with a single test I did (:sweat_smile:) so you can use it if you want! |
@mholt nice! Let me know how it goes and if you're able to optimize things one way or another or "make the impl better" whatever that means in this context :) Once you've got something I can give it a go here. We've basically got a highly parallel process which keeps open the "zip updater", and as files are finished, we're appending them to the zip and then shipping that off. I don't think that other library is maintained or active anymore so if you can whip something up I'd be more than happy to take yours ;) |
I mean, that lib works as far as I can tell, I don't know of another pure Go solution. You can try the latest commit I just pushed and see if it works for you. But if you're doing custom concurrency stuff maybe just best to use that lib directly... |
@mholt I'll give it a go and see how things fare. We haven't rolled out to production yet and so are still coding things up. |
@mholt with this new addition, and the way you implemented it, is it possible here to use a different compressor to get a smaller zip size? We're not necessarily concerned about how fast it takes to build the zip but more if we can get the zip size as small as possible. The files inside are all textual. |
@cdancy Set the |
@mholt I'm having no luck :( No matter what I use I can't get the zip of the file to not be significantly larger than what I get with the starry-zip library. Same 4 files I'm using there and here results in a 57K versus 764K respectively. Maybe I'm doing something wrong?
|
@cdancy I think you might need to use |
@mholt yeah I tried that as well but still nothing. When I open the zip written by the starry golang lib I see
I don't know ... |
I'm not sure if reusing the zip file after the zip writer wrote to it is a good idea. What if you have a fresh open file for the insert? |
Hey All,
Does this library support appending/inserting files into an existing zip? I've got a use-case where the disk space is limited and so short having to download X number of files and then zip them up I'd like to download them into a buffer in memory and then add that data as entries within a zip as I'm iterating over a list. Is that possible here? I saw you can append with tar just didn't see anything for zips.
Thanks in Advance,
Chris
The text was updated successfully, but these errors were encountered: