Bug 478347 - Pictures from old collection (network share) still in database after removing it
Summary: Pictures from old collection (network share) still in database after removing it
Status: REPORTED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Sqlite (show other bugs)
Version: 8.2.0
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-10 13:13 UTC by venik
Modified: 2024-02-16 21:40 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Removed collection still available with "null album" (62.07 KB, image/png)
2023-12-10 13:13 UTC, venik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description venik 2023-12-10 13:13:41 UTC
Created attachment 164068 [details]
Removed collection still available with "null album"

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Add SMB1 network share (not sure if it happens also on other scenarios) 
2. Remove the network share in Windows
3. Remove the collection in Digikam

OBSERVED RESULT

The images are not removed from the database.
Thumbnails and dates are still visible

EXPECTED RESULT

No longer entries related to the removed network are expected after collection removal

SOFTWARE/OS VERSIONS
Windows: 

ADDITIONAL INFORMATION
Unexpected photos seems to have null album (see attached photo).
I need an easy way to force the remove of these images. Kindly ask support.
Comment 1 Maik Qualmann 2023-12-10 13:45:15 UTC
First of all, it is normal for deleted pictures to have NULL album. We keep them for a while, so if they are added again we won't need to fully scan them anymore. But, images with NULL albums are usually not displayed or processed. So you must have a strange entry in your album root table.

To determine the cause I would need to have your digikam4.db. Or at least a list of the album root table to start with.

Maik
Comment 2 Maik Qualmann 2023-12-10 13:47:05 UTC
In which album mode are the deleted images displayed? Is a search album?

Maik
Comment 3 venik 2023-12-10 16:14:45 UTC
Thank you Maik for your support,
these are visible in "Dates" and "Timeline" sections.

The db is 148mb , if you explain me what you need I can try to support you (I am not expert).

Opening it with sqlite I see two AlbumRoot under Albums table (3, 6).

id	albumRoot	relativePath	date	caption	collection	icon	modificationDate
...
4964	6	/2003_12_23 Varie Casa	2003-12-21				2023-09-24T23:49:52.467
2902	6	/	2022-12-08				2023-12-09T14:46:10.574
3648	3	/Varie/x zia	2008-12-29				2022-01-09T22:47:37.192

But  under "Set root albums location" I have only one entry.
This is also visible in AlbumRoots table where I correctly have only one entry 

6	photo -HDD	0	2	volumeid:?uuid=c02303a9&fileuuid=c0e04540-3506-43bc-be15-b842d22850ed	/photo	1

Besides the possible bug that lead to these strange situation.. How can I recover?
Is it sufficient to delete all entries with albumRoot 3 ?

Thank you in advance
Comment 4 venik 2023-12-10 17:37:39 UTC
In order to solve I would also take into consideration create a new database.
Is there any option in digikam to this end?
Comment 5 Maik Qualmann 2023-12-10 18:24:00 UTC
The missing entry in the album root is definitely the problem. The first question is, is an album root correct? Otherwise, if you must have 2, try creating a dummy entry with id 3. You can then create the correct entry in digiKam using the update function (circle icon tool button) in the collection settings behind this dummy.

Maik
Comment 6 venik 2023-12-10 19:34:38 UTC
albumRoot = 3 refers to the network storage I removed,
This was removed from collections, but all the images and albums are still in the database!
I would like avoid to re-add it..

Now my question are 
1) how to recover? Should I just remove all the orphan images entries
(DELETE FROM Albums WHERE albumRoot = 3; ) 
should I expect orphan records? How should I make proper cleanup?

2) Why this happened? Is it correct my reproduction scenario?

3) is there a reset db or create new db option?
I also tried maintenance tool like "performance database cleaning" ... Apparently no benefits/change
Comment 7 Matthias Brändli 2024-02-16 21:40:25 UTC
Hello, I had a similar issue. I had added a read-only mounted external image collection, and then removed it again before it terminated scanning all entries.

No "null album" visible, but picture placeholders (no thumbnails) in the timeline. The database still contained albums referring to the non-existing AlbumRoot.

I have made a backup copy of digikam4.db and have executed `DELETE from Albums WHERE albumRoot <> 1;`, which fixed the problem for me. As Maik said it's ok to have Images with NULL album, I didn't clean up anything else.

Cheers
Matthias