extragear/multimedia/amarok/src/collection

Maximilian Kossick maximilian.kossick at googlemail.com
Fri Dec 26 20:10:08 CET 2008


SVN commit 901828 by mkossick:

do not delete files if an error occured during the file transfer
@devels: this has been fixed for SqlCollection, i.e. moves from the local collection or "organize files"
all other implementations of CollectionLocation have to be fixed too, especially MTP/iPod
BUG: 178701
CCMAIL: amarok-devel at kde.org


 M  +16 -1     CollectionLocation.cpp  
 M  +6 -0      CollectionLocation.h  
 M  +8 -3      sqlcollection/SqlCollectionLocation.cpp  
 M  +1 -1      sqlcollection/SqlCollectionLocation.h  


--- trunk/extragear/multimedia/amarok/src/collection/CollectionLocation.cpp #901827:901828
@@ -19,6 +19,7 @@
 
 #include "CollectionLocation.h"
 #include "Collection.h"
+#include "Debug.h"
 #include "QueryMaker.h"
 
 CollectionLocation::CollectionLocation()
@@ -325,8 +326,16 @@
 CollectionLocation::removeSourceTracks( const Meta::TrackList &tracks )
 {
     Meta::TrackList notDeletableTracks;
+    int count = m_tracksWithError.count();
+    debug() << "Transfer errors: " << count;
     foreach( Meta::TrackPtr track, tracks )
     {
+        if( m_tracksWithError.contains( track ) )
+        {
+            debug() << "transfer error for track " << track->playableUrl();
+            continue;
+        }
+
         if( !remove( track ) )
             notDeletableTracks.append( track );
     }
@@ -369,6 +378,12 @@
 {
     m_removeSources = removeSources;
 }
-    
 
+void
+CollectionLocation::transferError( const Meta::TrackPtr &track, const QString &error )
+{
+	DEBUG_BLOCK
+    m_tracksWithError.insert( track, error );
+}
+
 #include "CollectionLocation.moc"
--- trunk/extragear/multimedia/amarok/src/collection/CollectionLocation.h #901827:901828
@@ -156,6 +156,11 @@
         virtual bool movedByDestination( const Meta::TrackPtr &track ) const;
         virtual bool consideredByDestination( const Meta::TrackPtr &track ) const;
         virtual void setMovedByDestination( const Meta::TrackPtr &track, bool removeFromDatabase );
+    
+        /**
+        * tells the source location that an error occured during the transfer of the file
+        */
+        virtual void transferError( const Meta::TrackPtr &track, const QString &error );
         
         /**
          * Inserts a set of TrackPtrs directly into the database without needing to actuall move any files
@@ -255,6 +260,7 @@
         
         bool m_removeSources;
         QMap<Meta::TrackPtr, bool> m_tracksRemovedByDestination;
+        QMap<Meta::TrackPtr, QString> m_tracksWithError;
 };
 
 #endif
--- trunk/extragear/multimedia/amarok/src/collection/sqlcollection/SqlCollectionLocation.cpp #901827:901828
@@ -125,7 +125,7 @@
                 if( !dir.rmdir( name ) )
                     break;
             }
-                  
+
         }
         return removed;
     }
@@ -169,12 +169,17 @@
 SqlCollectionLocation::slotJobFinished( KJob *job )
 {
     DEBUG_BLOCK
-    m_jobs.remove( job );
+
+    debug() << "job.error: " << job->error() << " errorstring: " << job->errorString();
+
     if( job->error() )
     {
         //TODO: proper error handling
         warning() << "An error occurred when copying a file: " << job->errorString();
+        source()->transferError(m_jobs.value( job ), KIO::buildErrorString( job->error(), job->errorString() ) );
+        m_destinations.remove( m_jobs.value( job ) );
     }
+    m_jobs.remove( job );
     job->deleteLater();
     if( m_jobs.isEmpty() )
     {
@@ -238,7 +243,7 @@
                 name = QString( "%1 - %2" ).arg( track->artist()->name(), track->prettyName() );
 
             The::statusBar()->newProgressOperation( job, i18n( "Transferring: %1", name ) );
-            m_jobs.insert( job );
+            m_jobs.insert( job, track );
             job->start();
             jobsCreated = true;
         }
--- trunk/extragear/multimedia/amarok/src/collection/sqlcollection/SqlCollectionLocation.h #901827:901828
@@ -59,7 +59,7 @@
         SqlCollection *m_collection;
         QMap<Meta::TrackPtr, QString> m_destinations;
         bool m_overwriteFiles;
-        QSet<KJob*> m_jobs;
+        QMap<KJob*, Meta::TrackPtr> m_jobs;
 };
 
 #endif


More information about the Amarok-devel mailing list