Bug 272802 - Amarok collection scanner not handle correctly cross-renaming
Summary: Amarok collection scanner not handle correctly cross-renaming
Alias: None
Product: amarok
Classification: Applications
Component: Collections/Local (show other bugs)
Version: 2.6.90 (2.7 beta)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 2.8
Assignee: Amarok Developers
Depends on:
Reported: 2011-05-08 20:17 UTC by Nikita Krupenko
Modified: 2013-03-02 09:47 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.8


Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Krupenko 2011-05-08 20:17:27 UTC
Version:  (using KDE 4.4.5) 
OS:                Linux

Amarok not handle correctly, when I swap names of files in collection.

Reproducible: Always

Steps to Reproduce:
1. Place to the collection two audio files, for example 01.mp3 and 02.mp3.
2. Rename 01.mp3 to 02.mp3 and 02.mp3 to 01.mp3
3. Update collection or do a collection rescan

Actual Results:  
Error message:

The collection scanner reported the following errors:
GREPME MySQLe query failed! (1062) Duplicate entry 'amarok-sqltrackuid://ef4fbaf05bcffdb2b19263e8fafb2e50' for key 'uniqueid' on INSERT INTO urls (deviceid,rpath,directory,uniqueid) VALUES (-1,'./home/nekit/Music/01.mp3',1,'amarok-sqltrackuid://ef4fbaf05bcffdb2b19263e8fafb2e50');
In most cases this means that not all of your tracks were imported.
Further errors will only be reported on the console.

And only one file will be in the collection.

Expected Results:  
Should correctly update collection.

Collection rescan may help to fix collection. But may not.
Comment 1 Myriam Schweingruber 2011-05-10 02:56:25 UTC
Please upgrade to Amarok 2.4.1 final and try again, this is likely already fixed.
Comment 2 Nikita Krupenko 2011-06-13 13:03:33 UTC
Checked with version 2.4.1. No error message now, but only one file left in the collection. Also, full rescan don't fixes the collection.
Comment 3 Myriam Schweingruber 2011-06-13 22:44:52 UTC
Thank you for the feedback.
Comment 4 Aakash 2011-12-31 03:50:26 UTC
Tried it in Amarok 2.5 running on KDE 4.7.4 and the problem exists.
On swapping names in Dolphin and restarting Amarok, I see the same Error dialog box as mentioned in initial bug description.
Comment 5 Myriam Schweingruber 2011-12-31 12:48:13 UTC
Setting status to confirmed.
Comment 6 Matěj Laitl 2013-01-05 11:31:03 UTC
Reproducible in v2.6.90-71-g5d81710.

I fear that the only real solution would be to enclose database update in a SQL transaction, which is not supported in MyISAM tables Amarok currently uses in its MySQL database. :-(

Work-around is of course not to swap-rename files when Amarok is not running, instead do it in 2 steps and have Amarok's update collection fire in between. If you can afford to loose statistics/lyrics/labels, you can move the files out of collection and then back in.
Comment 7 Ralf Engels 2013-03-02 09:47:21 UTC
Git commit 0aeb1fafb3469d772b601441b29cdc5cb20d3589 by Ralf Engels.
Committed on 28/02/2013 at 16:45.
Pushed by rengels into branch 'master'.

Fix: amarok erroneously merges two albums

We are now keeping the information that an album artist is set until
the very end. So albums with an album artist and only a guessed
album artist are not merged.

Also add auto test for "Amarok collection scanner not handle correctly
Related: bug 216759

M  +6    -0    shared/collectionscanner/Album.cpp
M  +1    -0    shared/collectionscanner/Album.h
M  +60   -65   src/core-impl/collections/db/ScanResultProcessor.cpp
M  +1    -3    src/core-impl/collections/db/ScanResultProcessor.h
M  +1    -1    src/core-impl/collections/db/sql/SqlScanResultProcessor.cpp
M  +113  -5    tests/core-impl/collections/db/sql/TestSqlScanManager.cpp
M  +15   -1    tests/core-impl/collections/db/sql/TestSqlScanManager.h