Bug 324134 - SCAN : Images disappear after advanced rename
Summary: SCAN : Images disappear after advanced rename
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Scan (show other bugs)
Version: 5.0.0
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-27 20:10 UTC by Alexander Meshcheryakov
Modified: 2016-07-02 18:03 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.0.0


Attachments
attachment-11208-0.html (1.09 KB, text/html)
2014-08-07 08:29 UTC, Antonio
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Meshcheryakov 2013-08-27 20:10:01 UTC
After using advanced rename wizard renamed photos disappears from digiKam (but stays on disk) due to inconsistent database state.

Reproducible: Always

Steps to Reproduce:
1. Create album "TestAlbum" with images "testa.jpg" and "TESTB.jpg";
2. Select both images in digiKam and use rename tool with pattern "[file]{upper}" to make both file names uppercase.
Actual Results:  
File "testa.jpg" is correctly renamed to "TESTA.jpg", but it disappears from digiKam. It is not visible in album, cannot be find by search etc. However, digiKam keeps indicating that there is 2 items in "TestAlbum".

Maintenance tool "Scan for new images" does not restore visibility of lost photo.

The reason of disappearance is that after rename lost photo lacks record in table "ImageInformation".


Probably the bug is specific to MySQL database backend.
Comment 1 caulier.gilles 2014-06-16 07:41:44 UTC
*** Bug 336307 has been marked as a duplicate of this bug. ***
Comment 2 caulier.gilles 2014-08-07 07:05:38 UTC
Do you use sqlite or mysql database ?

Gilles Caulier
Comment 3 Antonio 2014-08-07 08:29:31 UTC
Created attachment 88142 [details]
attachment-11208-0.html

I use sqlite.
--
Antonio Angelo


2014-08-07 9:05 GMT+02:00 Gilles Caulier <caulier.gilles@gmail.com>:

> https://bugs.kde.org/show_bug.cgi?id=324134
>
> --- Comment #2 from Gilles Caulier <caulier.gilles@gmail.com> ---
> Do you use sqlite or mysql database ?
>
> Gilles Caulier
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You voted for the bug.
>
Comment 4 Alexander Meshcheryakov 2014-08-07 09:06:08 UTC
I used mysql database when I have encoutered this issue.
Comment 5 caulier.gilles 2014-08-07 15:57:03 UTC
Problem still reproducible using last digiKam 4.2.0 ?

Gilles Caulier
Comment 6 wuselwu 2014-12-13 08:57:08 UTC
I just encountered the same problem using Digikam 4.5.0 with MySQL-backend.
Comment 7 wuselwu 2014-12-13 09:23:54 UTC
More Info: 
Problem occured after batch renaming three pictures. 
After that, one pic remained, two have gone AWOL.
All Pictures are still visible in ordinary file browser, they are just missing in Digikam. 

Strange enough, when I use Digikam's filter mode and type in the file name of the missing pictures, Digikam finds (or thinks it finds) this picture. However, the displayed pic is the one which didn't get lost after the batch rename, not the missing one. I don't know why this picture should match the filter..
Comment 8 wuselwu 2014-12-13 09:33:28 UTC
It's reproducable: Batch rename seems to kick out the first picture of the renamed batch :(.

No way to repair the database - I tried moving the affected folder out and in of Digikam's picture path, rescanning in between, and so on: The pictures are lost for Digikam.

I gues the database has to be scrapped completely. I don't know how many photos I "lost" this way before noticing the bug. Seems to my kind of critical... and judging from above comments, it does not only affect the experimental MySQL backend.
Comment 9 caulier.gilles 2015-05-10 08:17:58 UTC
Maik,

I suspect a same dysfunction here in advance rename than BQM with ImageScanner...

Gilles
Comment 10 Maik Qualmann 2015-05-10 10:37:26 UTC
Gilles,

The malfunction of the description I can not reproduce. But it is possible with the renaming of one file, to remove the suffix. The file is then no longer visible in the album, and must be externally renamed again. That could be the problem.

Maik
Comment 11 caulier.gilles 2015-05-10 10:41:46 UTC
The file extension is a very sensible feature used by digiKam to identify quickly type mime without to parse first byte of file which is time consuming.

I recommend to drop file extension renaming in AdvanceRename tool to prevent all dysfunction. Note that is always possible use file manager as Dolphin, but in this case users do it with know risk.

We can also put a small tips in GUI about this problem.

Gilles
Comment 12 caulier.gilles 2015-06-25 13:05:53 UTC
New digiKam 4.11.0 is available with official PKG installer for OSX.

https://www.digikam.org/node/740

Can you reproduce the problem with this release ?
Comment 13 caulier.gilles 2015-08-13 08:02:36 UTC
digiKam 4.12.0 is out.

https://www.digikam.org/node/741

Problem still reproducible ?

Gilles Caulier
Comment 14 Gerard Dirkse 2015-11-10 10:14:55 UTC
Just hit this problem on 4.6.0, after renaming files in a folder (wanted the suffix to be lower case), only images left in the album are the ones that were lowercase to start with, from all other images in the folder (with uppercase suffix) have disappeared.  Entries are still in table 'Images', but no longer in 'Imageinformation'.  Reread metadata or rescan does not bring information back.  Please provide method for recovery from this bug.
Comment 15 Gerard Dirkse 2015-11-10 10:27:06 UTC
Could this be a 'feature' of MYSQL trigger behaviour for trigger 'delete-image' ? This trigger removes information from various places, including 'Imageinformation', after a DELETE. on table 'Images';
Comment 16 Gerard Dirkse 2015-11-10 10:29:39 UTC
Is the update of the image name implemented as a DELETE, then INSERT with same imageid ?, rather then an UPDATE SET....
Comment 17 Gerard Dirkse 2015-11-10 15:10:05 UTC
I have been able to recover the data in following way against the digikam database:

CREATE TEMPORARY TABLE `orphans` SELECT DISTINCT `id` FROM `Images` WHERE `id` NOT IN (SELECT `imageid` FROM `ImageInformation`);
DELETE from `Images` WHERE `id` in (SELECT * FROM `orphans`);

Then when digikam gets started again, images are recovered, not sure if this process leaves rubbish or not, but it appears not.  Would be nice if a database tool could do this, recover information that has been somehow lost.
Comment 18 swatilodha27 2016-05-23 18:38:33 UTC
I have tried this several times and this issue is also reproducible in digiKam Version 5.0.0-beta6
Comment 19 wuselwu 2016-06-02 07:32:50 UTC
I can confirm that the bug is still present in beta6 (MySQL). I had hoped that the MySQL rewrite would have fixed this bug.
Makes MySQL unusable if you want to avoid data loss...
Comment 20 wuselwu 2016-06-03 05:23:47 UTC
Maybe this is related to bug #357617: During batch rename of video files, I encounter strange behaviour, e.g. Digikam tries to rename files it has already renamed and so on. Is there some basic flaw in the batch rename logic triggering errors under certain conditions?
Comment 21 wuselwu 2016-06-03 05:29:33 UTC
Problem still present in 5.0b6: I simply cannot batch rename video files (not only MTS, but some times also MP4) reliably. Sometimes Digikam renames a bunch and then fails, often it tries to rename a file it has already renamed (and therefore claims - rightly - that the file is not present). Sometimes the error message stops the renaming process, sometimes the process goes on in the background?!?! I simply don't understand the behaviour, it's consistent only inasfar as that batch renaming video files fails.
Comment 22 wuselwu 2016-06-03 05:34:00 UTC
Sorry, added the above comment to the wrong bug.
Comment 23 wuselwu 2016-06-04 11:47:22 UTC
Additional observation which might be related:

Because of the missing pics after advanced rename, I DROPped the MySQL database and started from scratch. Digikam crashed twice after that, but then it scanned the collection anew. 

Everything seemed to be fine, but then I noticed that some pictures where missing. For my quite big collection I could  not look in every folder, but for the examples I found it seemed as if files with the same name, but the same extension in lower and upper case where missing (e.g. name.jpg and name.JPG). I renamed these pics and restarted Digikam, again two crashes (?!), but afterwards the missing pictures were there again. (As I said, only those missing files I noticed and which I renamed, might be that there are more missing...)

It might also be a problem with the MySQL database - in the beginning I had "Collation" as type, which I changed to some UTF8-type for the second attempt.

However, something seems to be wrong concerning the file name handling.
Comment 24 caulier.gilles 2016-06-04 11:57:49 UTC
Larx,

To be sure that problem remain with Mysql DB interface only, can you check if problem exist with a Sqlite database. The schema are not the same and SQlite interface is more advanced than Mysql one...

Thanks in advance

Gilles Caulier
Comment 25 wuselwu 2016-06-09 08:44:08 UTC
I filed the bug from comment 23 seperately, see #364131. 

I will try with SQLite when I find the time, however, SQLite is for my real life no option as it completely fails already for a familiy photo collection on a network drive to be handled from three different computers (digikam startup time especially on WLAN is to be measured in hours, a central MySQL server takes less than a minute...)
Comment 26 caulier.gilles 2016-06-09 10:10:22 UTC
yes, but Sqlite is the complete DB backend currently. We want to be sure that it work as expected.

We have a student working this summer on Mysql backend. Comparing both, especially one as Sqlite give the expected results will help to finalize Mysql interface.

Gilles Caulier
Comment 27 Maik Qualmann 2016-07-02 18:03:05 UTC
Git commit d18903fa644affd5f2b3c275b2544a54a9d64782 by Maik Qualmann.
Committed on 02/07/2016 at 17:30.
Pushed by mqualmann into branch 'master'.

make MySQL text fields case-sensitive
FIXED-IN: 5.0.0

M  +1    -2    NEWS
M  +81   -37   data/database/dbconfig.xml.cmake.in
M  +4    -1    libs/database/coredb/coredbschemaupdater.cpp

http://commits.kde.org/digikam/d18903fa644affd5f2b3c275b2544a54a9d64782