extragear/multimedia/amarok/src/collection/sqlcollection

Jeff Mitchell kde-dev at emailgoeshere.com
Thu Mar 5 04:33:47 CET 2009


SVN commit 935422 by mitchell:

PLEASE TEST

Right now, directories that no longer exist are never removed from the database.  As far as I can tell this is a bug, not a feature (dynamic collection detects existing directories that are no longer mounted, and does not deal with deleted directories).  In fact, the code detecting directory deletion up to this point has done the exact same thing as the code that detects changed mtimes -- i.e., it tells the scanner to scan it (even though it doesn't exist).

This commit should fix that by deleting directories that no longer exist from the database during an incremental scan.  This works in my testing and intuitively it's correct, but please test this.

CCMAIL: amarok-devel at kde.org


 M  +16 -1     ScanManager.cpp  


--- trunk/extragear/multimedia/amarok/src/collection/sqlcollection/ScanManager.cpp #935421:935422
@@ -360,6 +360,7 @@
             .arg( deviceIds ) );
 
     QList<int> changedFolderIds;
+    QList<int> deletedFolderIds;
 
     QStringList result;
     for( QListIterator<QString> iter( values ); iter.hasNext(); )
@@ -382,8 +383,8 @@
         else
         {
             // this folder has been removed
-            result << folder;
             changedFolderIds << id;
+            deletedFolderIds << id;
         }
     }
     {
@@ -412,6 +413,20 @@
             }
         }
     }
+    {
+        QString ids;
+        foreach( int id, deletedFolderIds )
+        {
+            if( !ids.isEmpty() )
+                ids += ',';
+            ids += QString::number( id );
+        }
+        if( !ids.isEmpty() )
+        {
+            QString sql = QString( "DELETE FROM directories WHERE id IN ( %1 );" ).arg( ids );
+            m_collection->query( sql );
+        }
+    }
     //debug() << "Scanning the following dirs: " << result;
     return result;
 }


More information about the Amarok-devel mailing list