2 ms·
FWIW ZIP files also allow for partial saves as each entry is stored in a separate stream so all you need to do is update the directory, which is placed at the e
by badsectoracula 9y ago
FWIW ZIP files also allow for partial saves as each entry is stored in a separate stream so all you need to do is update the directory, which is placed at the end of the file (in theory you could update archives in an append-only manner when saving and have a pack command to rebuild the ZIP file in order to remove the unnecessary data). It is just that (AFAIK) no program that uses ZIP as a generic container bothers with that (and besides, implementing the necessary logic for the partial saves might actually be the harder bit, regardless of the storage format).
- masklinn 9y ago> in theory you could update archives in an append-only manner when saving and have a pack command to rebuild the ZIP file in order to remove the unnecessary data In fact I'd expect a crash-safe "update" to do that, the in-line update only works if the revision of a file is no bigger than the old one. If you use appending methods to update the file, you write the new version of the existing file, you write a new central directory, and you remove the old directory entry. Only at that point should the update become visible.
- alkonaut 9y agoHandling a power outage during a save typically means writing to a new file and then handling it later. With a big zip I just copy the entire file (hoping that a file copy is reasonably fast) and then do in-place updates in the copy. If all the in-place updates in the copied zip work, then replace the original with the copy. I haven't found a reasonable way to do this that doesn't require making a copy of the whole original document. If sqlite did this elegantly, I'd switch in a heartbeat.