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
9.18k stars 792 forks source link

[Bug Report] Stash not updating the path of swapped files #2302

Open cj12312021 opened 2 years ago

cj12312021 commented 2 years ago

Describe the bug The conversation for this issue can be tracked starting at https://discord.com/channels/559159668438728723/559159910550732809/940735484110438400.

For context scenes in my library get mapped to directories as such {studio_name}/{scene_id_from_original_site}/{studio_name} - {scene_name}[resolution].mp4. I had a file with a path at /data/Collection/AllAnal/264/AllAnal - Ashley & Erin’s Gorgeous Gapes [1080p].mp4 in Stash which I later discovered was associated with the wrong scene. The file was actually https://tour.allanal.com/view/274/anal-tag-team-with-lana-erin. After realizing this I moved the file to the appropriate directory /data/Collection/AllAnal/274/AllAnal - Anal Tag Team with Lana & Erin [1080p].mp4. I later acquired the correct file and scanned it into Stash from a directory I have called /data/Collection/New. Once this file was scanned it was then moved to /data/Collection/AllAnal/264/AllAnal - Ashley & Erin’s Gorgeous Gapes [1080p].mp4. However, after another scan was kicked off stash never updated the path of this file. The following message was thrown in the log /data/Collection/AllAnal/264/AllAnal - Ashley & Erin’s Gorgeous Gapes [1080p].mp4 already exists. Duplicate of /data/Collection/AllAnal/274/AllAnal - Anal Tag Team with Lana & Erin [1080p].mp4.

The only way to get around this issue was by deleting the data stash had on both files and rescanning them into Stash.

Steps to Reproduce I was able to reproduce a scenario similar to what I just mentioned. Some steps might not be necessary but I state them anyway:

bnkai commented 2 years ago

Renaming/Moving a file is supported in stash for only a specific use case while swapping files is not officially supported. Pasting from discord

ATM stash can cope with 2 use cases. When a file is updated (replaced in place with a new one NOT yet in the db) it will find that the mod time is different and rescan the file to update file meta. This is for cases where a user wants to replace a scene with a higher quality one or modify a zip gallery to add/remove some images. The second case is moving/renaming a file. Stash will detect the new file during scan, will see that the hash/checksum is already in the database and will then try to see if the file is a duplicate or a rename. Swapping files is not a use case supported by stash so the end result is not predictable. The 2 above cases are simple enough so we can detect them during the scan without a lot of trouble and without wasting time (a single stat is used from what i remember). Swapping files is a bit more complex and it might need more that 1 pass of the scanner to resolve all issues. I think support for that (if implemented ) will be easier when the decoupling of scenes/galleries to files is done.