Bug 468586 - Deleting 2 tags only updates 1 tag to file
Summary: Deleting 2 tags only updates 1 tag to file
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Tags-Keywords (other bugs)
Version First Reported In: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-16 18:49 UTC by Kristian Karl
Modified: 2023-04-18 08:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 8.1.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kristian Karl 2023-04-16 18:49:41 UTC
SUMMARY
When deleting 2 different tags, only 1 of the tags are synced to sidecar file(s), resulting in out of sync state between database and sidecar files.

Digikam is asked to only read and write metadata to sidecar files.

STEPS TO REPRODUCE
1.  Set up digikam to only read and write metadata to sidecar files.
2. Create 2 different tags and assign them to images. Half of the images gets the first tag, the other half gets the second tag.
3. Apply the assignment. The sidecar files now have the correct tags
4. Open the Tag (left) side bar, select the 2 tags in step 2 and chose to delete them.

OBSERVED RESULT
In digikam the 2 tags are deleted, but half of the sidecar files still contains 1 one the tag. 
Selecting all images and then re-reading the metadata from the images (Item -> Reread Metadata From Selected Files) will find the tags who shoukd have been deleted and the now appear again in Digikam, which is not expected.

EXPECTED RESULT
All tags should have been removed from the sidecar files.

SOFTWARE/OS VERSIONS
Operating System: Ubuntu 22.10
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 5.19.0-38-generic (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION
Digikam built from sources  master branch commit 37193a9cf14141ff119ac468dae6c74dd061d8b2
Comment 1 Kristian Karl 2023-04-16 19:00:00 UTC
Also, I tested an verified the same unexpected result on digiKam-8.0.0-x86-64.appimage 
  Build date: 2023-04-12 15:32 (target: RelWithDebInfo)
  Revision: 66b84e1ba8f8003994fa398a669e1ccc4224a901
  Branch: HEAD
Comment 2 Maik Qualmann 2023-04-16 19:03:56 UTC
I can't reproduce the problem. Remember that reading from sidecar is always a merge of the metadata from the image. The sidecar has priority over the metadata of the image. So if the tag in the sidecar is deleted, the corresponding tag can reappear from the image.

Maik
Comment 3 Kristian Karl 2023-04-16 20:25:36 UTC
Ah, interesting! Maybe my repro steps was flawed or incorrect. I'll make a video of the problem tomorrow. 

One way to expose the problem is to ask Digikam to re-read from the sidecar files, but it is not necessary to do so.
After deleting the both tags, the sidecar files can be examined externally. Like using grep. When doing so, one of the tags will still exist in half of the images sidecar files, where as the other half of the sidecar files will be correct; tag is removed.
Comment 4 Maik Qualmann 2023-04-17 06:04:48 UTC
Ok, I skipped over the deletion of the tags yesterday. We start 2 individual jobs, since a progress manager job is already running then, the delete job for the other tag is no longer started, otherwise the system would become too slow and the SQLite database would be blocked. I'll see if we can combine the jobs...

Maik
Comment 5 Kristian Karl 2023-04-17 07:07:24 UTC
Ah, nice, thank you!

I did not mention it, but I'm running my digikam on a Maria/mysql instance. But I guess it does not matter in this case?

Also, I made a video https://youtu.be/BUHJIVCn-XY  using a clean install of kubuntu 22.10 and the latest snapshot of digikam appiage. But I think you understand the problem.
Comment 6 Maik Qualmann 2023-04-17 10:39:28 UTC
Git commit b8edbb8f17025199a4d9ea3e5b6fef99ad481516 by Maik Qualmann.
Committed on 17/04/2023 at 10:38.
Pushed by mqualmann into branch 'master'.

merge metadata write job when multiple tags are deleted
FIXED-IN: 8.1.0

M  +2    -1    NEWS
M  +4    -4    core/libs/album/manager/albummanager.h
M  +10   -11   core/libs/album/manager/albummanager_talbum.cpp
M  +10   -2    core/libs/tags/engine/tagmodificationhelper.cpp
M  +8    -2    core/libs/tags/manager/tagsmanager.cpp

https://invent.kde.org/graphics/digikam/commit/b8edbb8f17025199a4d9ea3e5b6fef99ad481516
Comment 7 Maik Qualmann 2023-04-17 11:02:34 UTC
I'll fix the broken compilation of the tests tonight.

Maik
Comment 8 Maik Qualmann 2023-04-17 16:24:10 UTC
Git commit 1e8cb779647a5921946c241909e82a961d6d13cc by Maik Qualmann.
Committed on 17/04/2023 at 16:23.
Pushed by mqualmann into branch 'master'.

fix compile the album model test

M  +2    -2    core/tests/albummodel/albummodel_utest.cpp

https://invent.kde.org/graphics/digikam/commit/1e8cb779647a5921946c241909e82a961d6d13cc
Comment 9 Kristian Karl 2023-04-18 08:58:38 UTC
I tested the fix this morning, and it works as expected now.
Thank you very much, I really appreciate your work <3