Version: 2.0.2 (using 4.2.2 (KDE 4.2.2), Kubuntu packages) Compiler: cc OS: Linux (x86_64) release 2.6.28-11-generic Most of the times I use "organize files" to move/rename files, I get empty directories (those in which originally the files were). If so, I must explore these directories and delete them. It would be great if Amarok automatically deletes empty directories after moving all the files to other location.
This is also true for the "Delete" function and is still present in 2.1.80.
It should also be configurable in Amarok's settings whether a dir with no music files should be treated as empty, and therefore get deleted once we move that music to our collection. There could be leftover garbage like playlists, images, text files.
Changing version, 2.0.2 was a very long time ago...
*** Bug 233197 has been marked as a duplicate of this bug. ***
commit 02686e6c2d9fb9697f48ce0137e8cd0aa6857873 Author: Casey Link <unnamedrambler@gmail.com> Date: Sun Apr 4 12:11:11 2010 -0400 Fix deletion, and remove empty directories in the process. Organizing files will now remove empty directories as well. BUG: 190881 diff --git a/src/core-impl/collections/sqlcollection/SqlCollectionLocation.cpp b/src/core-impl/collections/sqlcollection/SqlCollectionLocation.cpp index 66a5da2..f119956 100644 --- a/src/core-impl/collections/sqlcollection/SqlCollectionLocation.cpp +++ b/src/core-impl/collections/sqlcollection/SqlCollectionLocation.cpp @@ -124,10 +124,12 @@ SqlCollectionLocation::remove( const Meta::TrackPtr &track ) { bool removed; KUrl src = track->playableUrl(); - if( destination() == source() ) // is organize operation? + if( isGoingToRemoveSources() ) // is organize operation? { SqlCollectionLocation* destinationloc = dynamic_cast<SqlCollectionLocation*>( destination() ); src = destinationloc->m_originalUrls[track]; + if( src == track->playableUrl() ) + return false; } // we are going to delete it from the database only if is no longer on disk removed = !QFile::exists( src.path() ); @@ -152,6 +154,7 @@ SqlCollectionLocation::remove( const Meta::TrackPtr &track ) QFileInfo file( src.path() ); QDir dir = file.dir(); + dir.setFilter( QDir::NoDotAndDotDot ); const QStringList collectionFolders = m_collection->mountPointManager()->collectionFolders(); while( !collectionFolders.contains( dir.absolutePath() ) && !dir.isRoot() && dir.count() == 0 ) { @@ -285,9 +288,11 @@ void SqlCollectionLocation::slotRemoveJobFinished( KJob *job ) { DEBUG_BLOCK - if( job->error() ) + int error = job->error(); + if( error != 0 && error != KIO::ERR_DOES_NOT_EXIST ) { //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() ) ); } @@ -575,15 +580,17 @@ bool SqlCollectionLocation::startNextRemoveJob() Meta::TrackPtr track = m_removetracks.takeFirst(); KUrl src = track->playableUrl(); - if( destination() == source() ) // is organize operation? + debug() << "isGoingToRemoveSources() " << isGoingToRemoveSources(); + if( isGoingToRemoveSources() ) // is organize operation? { SqlCollectionLocation* destinationloc = dynamic_cast<SqlCollectionLocation*>( destination() ); src = destinationloc->m_originalUrls[track]; + if( src == track->playableUrl() ) { + debug() << "src == dst"; + break; + } } - if( src == track->playableUrl() ) // src == dst - break; - KIO::DeleteJob *job = 0; src.cleanPath(); diff --git a/src/core/collections/CollectionLocation.cpp b/src/core/collections/CollectionLocation.cpp index 80ab2b7..27e9efd 100644 --- a/src/core/collections/CollectionLocation.cpp +++ b/src/core/collections/CollectionLocation.cpp @@ -48,6 +48,7 @@ CollectionLocation::CollectionLocation( const Collections::Collection* parentCol , m_parentCollection( parentCollection ) , m_removeSources( false ) , m_isRemoveAction( false ) + , m_noRemoveConfirmation( false ) { //nothing to do }
Still doesn't remove empty dirs, when some of files to be moved have src == dest, and some not. debug output: http://pastebin.com/VYTRqsSc
Wasn't this fixed in 2.3.1?
at most partially, nothing changed since my last comment
Git commit 0c7c4872e9bd923b1b10fe2ecd84f2630d8e6024 by Sergey Ivanov. Committed on 04/02/11 at 18:08. Pushed by ivanov into branch 'master'. Fixed empty folders removeing after collection organization. BUG: 190881 M +1 -0 ChangeLog M +2 -23 src/core-impl/collections/support/FileCollectionLocation.cpp M +0 -1 src/core-impl/collections/support/FileCollectionLocation.h M +31 -1 src/core/collections/CollectionLocation.cpp http://commits.kde.org/amarok/0c7c4872e9bd923b1b10fe2ecd84f2630d8e6024