Bug 137645

Summary: incr. collection scanning out of sync
Product: [Applications] amarok Reporter: Roland <rolandg>
Component: generalAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Roland 2006-11-20 23:18:26 UTC
Version:           1.4-SVN (20.11.2006) (using KDE KDE 3.5.5)
Installed from:    SuSE RPMs
Compiler:          gcc version 3.3.5 20050117 (prerelease) (SUSE Linux) 
OS:                Linux

the incremental collection scanning runs all the time. It detects something to do, but is not able to fix it. The following output shows up every minute !


amarok: BEGIN: ScanController::ScanController(CollectionDB*, bool, const QStringList&)
amarok: BEGIN: void ScanController::initIncremental()
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/c/Cat Stevens
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/c/Chris Rea
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/e/Enya
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/m/Moby
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/m/Moby/Moby - Go - The Very Best Of Moby
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/t/The Corrs
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/v/Various
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/v/Various/Ministry of Sound
amarok:     [ScanController] Collection was modified.
amarok: END__: void ScanController::initIncremental() - Took 0.71s
amarok: END__: ScanController::ScanController(CollectionDB*, bool, const QStringList&) - Took 0.71s
amarok: BEGIN: virtual void ThreadWeaver::Thread::run()
amarok: BEGIN: virtual bool ScanController::doJob()
amarok: BEGIN: void CollectionDB::createTables(bool)
amarok: END__: void CollectionDB::createTables(bool) - Took 0.08s
amarok: BEGIN: void CollectionDB::prepareTempTables()
amarok: END__: void CollectionDB::prepareTempTables() - Took 0.1s
amarok:     [KDE::ProgressBar::ProgressBar(QWidget*, QLabel*)]
amarok:     [ScanController] itemcount event: 64
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Christopher Robin.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Christopher Robin.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Girl, You'll Be A Woman Soon.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Girl, You''ll Be A Woman Soon.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens & James Taylor - Cats in the Cradle .mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens & James Taylor - Cats in the Cradle .mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Year of the Cat.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Year of the Cat.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Brown Eyed Girl.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Brown Eyed Girl.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Seasons In The Sun.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Seasons In The Sun.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Fiddle- Celtic Gaelic Irish - Enya - Celtic Fiddle.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Fiddle- Celtic Gaelic Irish - Enya - Celtic Fiddle.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya - Celtic Melt, now with Loreena McKennitt, Afro Celt, Steeleye Span.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya - Celtic Melt, now with Loreena McKennitt, Afro Celt, Steeleye Span.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya_-_Main_Theme_of_Final_Fantasy_Iv.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya_-_Main_Theme_of_Final_Fantasy_Iv.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/celtica Enya - Celtic Melt (now with Loreena McKennitt, Afro Celt, Steeleye Span).mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/celtica Enya - Celtic Melt (now with Loreena McKennitt, Afro Celt, Steeleye Span).mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya - Paint The Sky With Stars - 12 - Paint the Sky with Stars.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya - Paint The Sky With Stars - 12 - Paint the Sky with Stars.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya by DJ Bacon.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya by DJ Bacon.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya - Dances with Wolves - Theme.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya - Dances with Wolves - Theme.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/t/The Corrs/The Corrs - MTV Unplugged (Entire Album) - 1999.mp3 has same UID as new file at ./media/MEDIAx/Music/t/The Corrs/The Corrs - MTV Unplugged (Entire Album) - 1999.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/v/Various/Ministry of Sound/ministry of sound - Chill Out Session - Future Sound of London.mp3 has same UID as new file at ./media/MEDIAx/Music/v/Various/Ministry of Sound/ministry of sound - Chill Out Session - Future Sound of London.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/v/Various/Ministry of Sound/Cafe Del Mar - Ministry Of Sound - The Chillout Session Ibiza 2006.mp3 has same UID as new file at ./media/MEDIAx/Music/v/Various/Ministry of Sound/Cafe Del Mar - Ministry Of Sound - The Chillout Session Ibiza 2006.mp3
amarok: BEGIN: void CollectionDB::copyTempTables()
amarok: END__: void CollectionDB::copyTempTables() - Took 0.093s
amarok: END__: virtual bool ScanController::doJob() - Took 9.4s
amarok: END__: virtual void ThreadWeaver::Thread::run() - Took 9.4s
amarok: [CollectionDB] JobFinishedEvent from Incremental ScanController received.
amarok: [ThreadWeaver] Job completed: CollectionScanner. Jobs pending: 0
amarok: BEGIN: virtual ScanController::~ScanController()
amarok: END__: virtual ScanController::~ScanController() - Took 0.00021s
amarok: [virtual KDE::ProgressBar::~ProgressBar()]
amarok: BEGIN: ScanController::ScanController(CollectionDB*, bool, const QStringList&)
amarok: BEGIN: void ScanController::initIncremental()
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/c/Cat Stevens
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/c/Chris Rea
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/e/Enya
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/m/Moby
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/m/Moby/Moby - Go - The Very Best Of Moby
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/t/The Corrs
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/v/Various
amarok:     [ScanController] Collection dir changed: /media/MEDIAx/Music/v/Various/Ministry of Sound
amarok:     [ScanController] Collection was modified.
amarok: END__: void ScanController::initIncremental() - Took 0.5s
amarok: END__: ScanController::ScanController(CollectionDB*, bool, const QStringList&) - Took 0.51s
amarok: BEGIN: virtual void ThreadWeaver::Thread::run()
amarok: BEGIN: virtual bool ScanController::doJob()
amarok: BEGIN: void CollectionDB::createTables(bool)
amarok: END__: void CollectionDB::createTables(bool) - Took 0.04s
amarok: BEGIN: void CollectionDB::prepareTempTables()
amarok: END__: void CollectionDB::prepareTempTables() - Took 0.099s
amarok:     [KDE::ProgressBar::ProgressBar(QWidget*, QLabel*)]
amarok:     [ScanController] itemcount event: 64
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Christopher Robin.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Christopher Robin.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Girl, You'll Be A Woman Soon.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Girl, You''ll Be A Woman Soon.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens & James Taylor - Cats in the Cradle .mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens & James Taylor - Cats in the Cradle .mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Year of the Cat.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Year of the Cat.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Brown Eyed Girl.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Brown Eyed Girl.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Seasons In The Sun.mp3 has same UID as new file at ./media/MEDIAx/Music/c/Cat Stevens/Cat Stevens - Seasons In The Sun.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Fiddle- Celtic Gaelic Irish - Enya - Celtic Fiddle.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Fiddle- Celtic Gaelic Irish - Enya - Celtic Fiddle.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya - Celtic Melt, now with Loreena McKennitt, Afro Celt, Steeleye Span.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya - Celtic Melt, now with Loreena McKennitt, Afro Celt, Steeleye Span.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya_-_Main_Theme_of_Final_Fantasy_Iv.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya_-_Main_Theme_of_Final_Fantasy_Iv.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/celtica Enya - Celtic Melt (now with Loreena McKennitt, Afro Celt, Steeleye Span).mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/celtica Enya - Celtic Melt (now with Loreena McKennitt, Afro Celt, Steeleye Span).mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya - Paint The Sky With Stars - 12 - Paint the Sky with Stars.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya - Paint The Sky With Stars - 12 - Paint the Sky with Stars.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya by DJ Bacon.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya by DJ Bacon.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/e/Enya/Enya - Dances with Wolves - Theme.mp3 has same UID as new file at ./media/MEDIAx/Music/e/Enya/Enya - Dances with Wolves - Theme.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/t/The Corrs/The Corrs - MTV Unplugged (Entire Album) - 1999.mp3 has same UID as new file at ./media/MEDIAx/Music/t/The Corrs/The Corrs - MTV Unplugged (Entire Album) - 1999.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/v/Various/Ministry of Sound/ministry of sound - Chill Out Session - Future Sound of London.mp3 has same UID as new file at ./media/MEDIAx/Music/v/Various/Ministry of Sound/ministry of sound - Chill Out Session - Future Sound of London.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/v/Various/Ministry of Sound/Cafe Del Mar - Ministry Of Sound - The Chillout Session Ibiza 2006.mp3 has same UID as new file at ./media/MEDIAx/Music/v/Various/Ministry of Sound/Cafe Del Mar - Ministry Of Sound - The Chillout Session Ibiza 2006.mp3
amarok: BEGIN: void CollectionDB::copyTempTables()
amarok: END__: void CollectionDB::copyTempTables() - Took 0.095s
amarok: END__: virtual bool ScanController::doJob() - Took 9.5s
amarok: END__: virtual void ThreadWeaver::Thread::run() - Took 9.5s
amarok: [CollectionDB] JobFinishedEvent from Incremental ScanController received.
amarok: [ThreadWeaver] Job completed: CollectionScanner. Jobs pending: 0
amarok: BEGIN: virtual ScanController::~ScanController()
amarok: END__: virtual ScanController::~ScanController() - Took 0.00021s
amarok: [virtual KDE::ProgressBar::~ProgressBar()]
Comment 1 Roland 2006-11-20 23:38:29 UTC
how to reproduce

find a directory in your collection, where some mp3 files are located; 

e.g.:
cd Music/t/test> 
ls -l 
total 832
drwxr-xr-x   2 roland users  16384 2006-05-20 00:45 ./
drwxr-xr-x  44 roland users  16384 2006-10-20 01:06 ../
-rwxr-xr-x   1 roland users 381346 2006-07-22 02:48 Kappee%2fxxx.mp3*
-rwxr-xr-x   1 roland users 381346 2006-07-22 02:48 Verità supposte-05 - Limiti.mp3*

create an empty directory 
mkdir x
ls -l

total 848
drwxr-xr-x   3 roland users  16384 2006-11-20 23:32 ./
drwxr-xr-x  44 roland users  16384 2006-10-20 01:06 ../
-rwxr-xr-x   1 roland users 381346 2006-07-22 02:48 Kappee%2fxxx.mp3*
-rwxr-xr-x   1 roland users 381346 2006-07-22 02:48 Verità supposte-05 - Limiti.mp3*
drwxr-xr-x   2 roland users  16384 2006-11-20 23:32 x/


--> the debug output of amarok will show:
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/t/test/Kappee%2fxxx.mp3 has same UID as new file at ./media/MEDIAx/Music/t/test/Kappee%2fxxx.mp3
amarok:     [CollectionDB] [ERROR!] Already-scanned file at /media/MEDIAx/Music/t/test/Verità supposte-05 - Limiti.mp3 has same UID as new file at ./media/MEDIAx/Music/t/test/Verità supposte-05 - Limiti.mp3

Comment 2 Jeff Mitchell 2006-12-03 23:52:16 UTC
SVN commit 610256 by mitchell:

Hacky fix for wonky AFT/DynCol interaction

BUG: 137645


 M  +12 -4     collectiondb.cpp  


--- trunk/extragear/multimedia/amarok/src/collectiondb.cpp #610255:610256
@@ -3052,7 +3052,10 @@
             //stat the original URL
             QString absPath = mpm->getAbsolutePath( uniqueids[2].toInt(), uniqueids[0] );
             //debug() << "At doAFTStuff, stat-ing file " << absPath << endl;
-            bool statSuccessful = QFile::exists( absPath );
+            bool statSuccessful = false;
+            bool pathsSame = absPath == bundle->url().path();
+            if( !pathsSame )
+                statSuccessful = QFile::exists( absPath );
             if( statSuccessful ) //if true, new one is a copy
                 warning() << "Already-scanned file at " << absPath << " has same UID as new file at " << bundle->url().path() << endl;
             else  //it's a move, not a copy, or a copy and then both files were moved...can't detect that
@@ -3066,7 +3069,8 @@
                       << currurl
                       << currdir
                       << currid ) );
-                emit fileMoved( absPath, bundle->url().path(), bundle->uniqueId() );
+                if( !pathsSame )
+                    emit fileMoved( absPath, bundle->url().path(), bundle->uniqueId() );
             }
         }
         //okay then, url already found in temporary table but different uniqueid
@@ -3112,7 +3116,10 @@
             //stat the original URL
             QString absPath = mpm->getAbsolutePath( nonTempIDs[2].toInt(), nonTempIDs[0] );
             //debug() << "At doAFTStuff part 2, stat-ing file " << absPath << endl;
-            bool statSuccessful = QFile::exists( absPath );
+            bool statSuccessful = false;
+            bool pathsSame = absPath == bundle->url().path();
+            if( !pathsSame )
+                statSuccessful = QFile::exists( absPath );
             if( statSuccessful ) //if true, new one is a copy
                 warning() << "Already-scanned file at " << absPath << " has same UID as new file at " << currurl << endl;
             else  //it's a move, not a copy, or a copy and then both files were moved...can't detect that
@@ -3126,7 +3133,8 @@
                                 , currurl
                                 , currid
                                 , currdir ) );
-                emit fileMoved( absPath, bundle->url().path(), bundle->uniqueId() );
+                if( !pathsSame )
+                    emit fileMoved( absPath, bundle->url().path(), bundle->uniqueId() );
             }
         }
         else if( nonTempIDs.empty() )