Add support for deleting individual images from zip galleries#7107
Open
NebuPookins wants to merge 1 commit into
Open
Add support for deleting individual images from zip galleries#7107NebuPookins wants to merge 1 commit into
NebuPookins wants to merge 1 commit into
Conversation
When deleting an image whose file lives inside a zip/cbz archive, remove just that entry from the zip. (Previously, these deletion requests would be silently ignored). Uses a deferred rewrite strategy: entries are accumulated during the transaction and the zip is rewritten at Commit() time, keeping bulk deletions efficient. Also extracts a shared decodeZipEntryNames helper to avoid duplicating charset-detection logic between the zip FS reader and the rewriter.
Gykes
requested changes
Jul 17, 2026
Gykes
left a comment
Collaborator
There was a problem hiding this comment.
Just a quick static review. Didn't test anything
Comment on lines
+227
to
+238
| // Rewrite each zip that has pending entry removals. | ||
| for zipPath, entries := range d.zipEntries { | ||
| tmpPath, err := RemoveEntriesFromZip(zipPath, entries) | ||
| if err != nil { | ||
| logger.Warnf("Error rewriting zip %q: %v", zipPath, err) | ||
| continue | ||
| } | ||
| if err := d.RenamerRemover.Rename(tmpPath, zipPath); err != nil { | ||
| _ = d.RenamerRemover.Remove(tmpPath) | ||
| logger.Warnf("Error applying zip rewrite for %q: %v", zipPath, err) | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
Rewriting the zip would shrink it on disk but I dont think it updates the zips stored Size. I believe this would break the gallery until you do another scan.
The zip rewrite also runs in the post commit hook so any kind of failure here would mean that the DB would be inconsistent with the archive and the image will be picked back up on scan.
| // directory, excluding all entries whose relative paths (using forward slashes) appear in | ||
| // entriesToRemove. Returns the path of the temporary file. The caller is responsible for | ||
| // atomically replacing the original zip with the temp file, or cleaning it up on rollback. | ||
| func RemoveEntriesFromZip(zipPath string, entriesToRemove []string) (string, error) { |
Collaborator
There was a problem hiding this comment.
This seems to ignore Trash path. This would permanently delete the image rather than pushing it to the trash path (if set)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When deleting an image whose file lives inside a zip/cbz archive, remove just that entry from the zip. (Previously, these deletion requests would be silently ignored).
Uses a deferred rewrite strategy: entries are accumulated during the transaction and the zip is rewritten at Commit() time, keeping bulk deletions efficient.
Also extracts a shared decodeZipEntryNames helper to avoid duplicating charset-detection logic between the zip FS reader and the rewriter.
Related Issue
Fixes #7106
Testing
Deleted an image in a zip gallery, confirmed (by inspecting the zip) that the file actually got deleted.
Checklist
AI Usage Disclosure
Collaborated with AI to write this code change.