stashapp / stash

An organizer for your porn, written in Go. Documentation: https://docs.stashapp.cc
https://stashapp.cc/
GNU Affero General Public License v3.0
8.94k stars 783 forks source link

[Bug Report] Deleting a duplicated gallery makes all images of the remaining gallery disappear #4163

Open peresabcod opened 1 year ago

peresabcod commented 1 year ago

Describe the bug Having two indexed image galleries with the same files inside (same CRC), if you delete one of them, with this option:

Delete gallery folder/zip file and any images not attached to any other gallery.

All reference to the images in the remaining gallery disappear, only files that where not duplicated remain The files are still on the disk, but they cannot be reindexed unless you delete the gallery with the option

Delete generated supporting files

And scan the folder again

I work with zip file galleries, but I'm quite sure that it happens with normal folders too. The problem is how the program manages and indexes duplicated files

To Reproduce Steps to reproduce the behavior:

  1. Put some image files in a zip file, name it Gallery 1
  2. Duplicate the zip file, so you end up with Gallery1.zip and Gallery2.zip
  3. Scan
  4. Two new galleries will appear
  5. Remove Gallery 2, checking the option "Delete gallery folder/zip file and any images not attached to any other gallery.". Gallery 2.zip disappears from dik, Gallery1.zip still there
  6. Open Gallery 1 in stash
  7. It's now empty, no files, no thumbnails

Expected behavior Deleting a gallery that has duplicated images should check and only decrement the image count if the image it's present in another one, i.e. from 2 to 1, not remove all references

Stash Version: (from Settings -> About): v0.22.1

Desktop (please complete the following information):

Additional context I think this is related to another bug I submited some time ago: https://github.com/stashapp/stash/issues/3849. Duplicated images should not affect the behaviour of a gallery

MyDirtyAccount commented 10 months ago

FWIW, I tried to reproduce this in a Chromium-based browser (Arc) running against Stash v0.23.0 today, and could not. (Just the 1 gallery I deleted was properly removed - the other remained, with all duplicate images intact.)