Summary: | All pending files deleted when while renaming/moving a conflicting filename error appears | ||
---|---|---|---|
Product: | [Applications] amarok | Reporter: | Iñaki <iceclow> |
Component: | Collections/Local | Assignee: | Amarok Developers <amarok-bugs-dist> |
Status: | RESOLVED FIXED | ||
Severity: | major | CC: | matej, nospamformike, ralf-engels |
Priority: | NOR | ||
Version: | 2.4-GIT | ||
Target Milestone: | 2.4.0 | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 2.4 |
Description
Iñaki
2010-11-23 22:30:42 UTC
commit bc9e86bc350137623667baada2c4bacf256400a1 branch master Author: Sergey Ivanov <123kash@gmail.com> Date: Wed Jan 5 22:08:52 2011 +0300 Leave all pending files untouched in case of error/conflict during tracks moving. BUG: 257739 diff --git a/ChangeLog b/ChangeLog index e451b12..9f529c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ VERSION 2.4-Beta 2 * Fixed some broken radio stream URLs. BUGFIXES: + * Leave all pending files in case of error/conflict during tracks moving. (BR 257739) * Fix crash when moving tracks between collections. (BR 253033) * Fixed issue with UMS Collection that made amarok to delete original track instead of newly copied one. (BR 238915) diff --git a/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp b/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp index f729c31..6322c44 100644 --- a/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp +++ b/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp @@ -364,13 +364,17 @@ void SqlCollectionLocation::slotJobFinished( KJob *job ) { DEBUG_BLOCK + + Meta::TrackPtr track = m_jobs.value( job ); 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 ) ); + source()->transferError( track, KIO::buildErrorString( job->error(), job->errorString() ) ); + m_destinations.remove( track ); } + else + source()->transferSuccessful( track ); m_jobs.remove( job ); job->deleteLater(); @@ -381,21 +385,20 @@ void SqlCollectionLocation::slotRemoveJobFinished( KJob *job ) { DEBUG_BLOCK - int error = job->error(); - if( error != 0 && error != KIO::ERR_DOES_NOT_EXIST ) + Meta::TrackPtr track = m_removejobs.value( job ); + if( job->error() ) { //TODO: proper error handling - debug() << "KIO::ERR_DOES_NOT_EXIST" << KIO::ERR_DOES_NOT_EXIST; warning() << "An error occurred when removing a file: " << job->errorString(); - transferError(m_removejobs.value( job ), KIO::buildErrorString( job->error(), job->errorString() ) ); + transferError( track, KIO::buildErrorString( job->error(), job->errorString() ) ); } else { // Remove the track from the database - remove( m_removejobs.value( job ) ); + remove( track ); //we assume that KIO works correctly... - transferSuccessful( m_removejobs.value( job ) ); + transferSuccessful( track ); } m_removejobs.remove( job ); @@ -420,13 +423,9 @@ void SqlCollectionLocation::slotTransferJobFinished( KJob* job ) // that were successfully copied foreach( const Meta::TrackPtr &track, m_destinations.keys() ) { - if( !QFileInfo( m_destinations[ track ] ).exists() ) - m_destinations.remove( track ); + if( QFile::exists( m_destinations[ track ] ) ) + insert( track, m_destinations[ track ] ); m_originalUrls[track] = track->playableUrl(); - debug() << "inserting original url" << m_originalUrls[track]; - // report successful transfer with the original url - source()->transferSuccessful( track ); - insert( track, m_destinations[ track ] ); } debug () << "m_originalUrls" << m_originalUrls; m_collection->scanManager()->unblockScan(); @@ -443,9 +442,7 @@ void SqlCollectionLocation::slotTransferJobAborted() // that were successfully copied foreach( const Meta::TrackPtr &track, m_destinations.keys() ) { - if( !QFileInfo( m_destinations[ track ] ).exists() ) - m_destinations.remove( track ); - else + if( QFile::exists( m_destinations[ track ] ) ) insert( track, m_destinations[ track ] ); // was already copied, so have to insert it in the db m_originalUrls[track] = track->playableUrl(); } @@ -548,8 +545,7 @@ bool SqlCollectionLocation::startNextJob( const Transcoding::Configuration confi if( src.equals( dest ) ) { - debug() << "move to itself found"; - source()->transferSuccessful( track ); + warning() << "move to itself found: " << info.absoluteFilePath(); m_transferjob->slotJobFinished( 0 ); if( m_sources.isEmpty() ) return false; diff --git a/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp b/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp index 0ae0b59..3fb5e61 100644 --- a/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp +++ b/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp @@ -475,8 +475,7 @@ MediaDeviceHandler::copyNextTrackToDevice() if ( !m_tracksToCopy.isEmpty() ) { // Pop the track off the front of the list - track = m_tracksToCopy.first(); - m_tracksToCopy.removeFirst(); + track = m_tracksToCopy.takeFirst(); // Copy the track and check result if ( !privateCopyTrackToDevice( track ) ) diff --git a/src/core-impl/collections/umscollection/handler/UmsHandler.cpp b/src/core-impl/collections/umscollection/handler/UmsHandler.cpp index 4535ae1..41a2978 100644 --- a/src/core-impl/collections/umscollection/handler/UmsHandler.cpp +++ b/src/core-impl/collections/umscollection/handler/UmsHandler.cpp @@ -707,6 +707,8 @@ UmsHandler::slotCopyingDone( KIO::Job* job, KUrl from, KUrl to, time_t mtime, bo m_files.insert( to.path(), destTrack ); slotFinalizeTrackCopy( track ); } + else + slotCopyTrackFailed( track ); } void diff --git a/src/core/collections/CollectionLocation.cpp b/src/core/collections/CollectionLocation.cpp index c5b07ac..63db209 100644 --- a/src/core/collections/CollectionLocation.cpp +++ b/src/core/collections/CollectionLocation.cpp @@ -341,7 +341,6 @@ CollectionLocation::slotCopyOperationFinished() void CollectionLocation::slotRemoveOperationFinished() { - DEBUG_BLOCK emit finishRemove(); } @@ -360,7 +359,6 @@ CollectionLocation::slotShowDestinationDialogDone() void CollectionLocation::slotShowRemoveDialogDone() { - DEBUG_BLOCK emit startRemove(); } *** Bug 266008 has been marked as a duplicate of this bug. *** |