Fix tag caching that causes wrong tags from folders#1295
Open
Jakeler wants to merge 4 commits into
Open
Conversation
When using --folder-as-tags, assets in directories with identical names at different path levels were incorrectly assigned to the same tag. The root cause was that the tag cache was using Tag.Name (the leaf node name) as the cache key instead of Tag.Value (the full tag path). This caused collisions when multiple directories had the same name but different parent paths. Fixes simulot#1262
enhance folder-as-tags tests, checks tags on each file against the expected (instead of just checking if all tags exist)
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.
Fix for #1262
The tags were being cached using
t.Nameas the cache key. However,t.Nameis just the last component of the tag path. When multiple files have tags with the same leaf name but different full paths (e.g., "test/1 dir/same" and "test/2 dir/same"), they would collide in the cache because they both hadName="same".Solution: Changed the cache key to use
t.Value(the full tag path):Testing
Test_FromFolder/folder-as-tagsI did run the tests locally, they pass and are an good indicator for this issue. Sometimes the testcase/check fails even though the tags are actually applied, because it depends on immich-server updating the metadata (seems to involve reading the sidecar) fast enough. I don't see any way to wait for background job completion on the api, only to trigger jobs, which happens automatically anyway.
We can split off the last commit if that's a problem, but the precise check is useful to find more tagging issues, like the missing tags from duplicates (#1069).