Commit 0c7c4872 authored by Sergey Ivanov's avatar Sergey Ivanov
Browse files

Fixed empty folders removeing after collection organization.

BUG: 190881
parent eabad90a
......@@ -20,6 +20,7 @@ VERSION 2.4.1
<bhargav.1191@gmail.com>. (BR 248690)
BUGFIXES:
* Fixed empty folders removeing after collection organization. (BR 190881)
* Fixed crash when trying to load cover for track/album without artist. (BR 263256)
* Fixed linking on Solaris 11 (and others?). (BR 264112)
* Fixed temporary podcast download filenames that were to long by using MD5 hash instead.
......
......@@ -75,27 +75,7 @@ FileCollectionLocation::remove( const Meta::TrackPtr &track )
return false;
}
debug() << "removing dirs for : " << track->playableUrl().path();
// the file should be removed already, so we can clean the dirs
bool removed = !QFile::exists( track->playableUrl().path() );
if( m_removeEmptyDirs && removed)
{
QFileInfo file( track->playableUrl().path() );
QDir dir = file.dir();
dir.setFilter( QDir::NoDotAndDotDot );
while( !dir.isRoot() && dir.count() == 0 )
{
debug() << "attempting to rmdir << " << dir;
const QString name = dir.dirName();
dir.cdUp();
if( !dir.rmdir( name ) )
break;
else
debug() << "rmdir succeeded";
}
}
return removed;
return !QFile::exists( track->playableUrl().path() );
}
void FileCollectionLocation::startRemoveJobs()
{
......@@ -159,10 +139,9 @@ void FileCollectionLocation::removeUrlsFromCollection(const Meta::TrackList& sou
void FileCollectionLocation::showRemoveDialog( const Meta::TrackList &tracks )
{
DEBUG_BLOCK
Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate();
m_removeEmptyDirs = delegate->deleteEmptyDirs( this );
if( !isHidingRemoveConfirm() )
{
Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate();
const bool del = delegate->reallyDelete( this, tracks );
if( !del )
......
......@@ -47,7 +47,6 @@ class FileCollectionLocation : public CollectionLocation
QMap<KJob*, Meta::TrackPtr> m_removejobs;
Meta::TrackList m_removetracks;
bool m_removeEmptyDirs;
};
} //namespace Collections
......
......@@ -417,19 +417,24 @@ void
CollectionLocation::slotFinishRemove()
{
DEBUG_BLOCK
Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate();
if( m_tracksWithError.size() > 0 )
{
Collections::CollectionLocationDelegate *delegate = Amarok::Components::collectionLocationDelegate();
delegate->errorDeleting( this, m_tracksWithError.keys() );
m_tracksWithError.clear();
}
QStringList dirsToRemove;
debug() << "remove finished updating";
foreach( Meta::TrackPtr track, m_tracksSuccessfullyTransferred )
{
if(!track)
continue;
if( track->playableUrl().isLocalFile() )
dirsToRemove.append( track->playableUrl().directory( KUrl::AppendTrailingSlash ) );
QScopedPointer<Capabilities::UpdateCapability> uc( track->create<Capabilities::UpdateCapability>() );
if(!uc)
continue;
......@@ -437,6 +442,31 @@ CollectionLocation::slotFinishRemove()
uc->collectionUpdated();
}
if( !dirsToRemove.isEmpty() && delegate->deleteEmptyDirs( this ) )
{
debug() << "Removeing empty directories";
dirsToRemove.removeDuplicates();
dirsToRemove.sort();
while( !dirsToRemove.isEmpty() )
{
QDir dir( dirsToRemove.takeLast() );
if( !dir.exists() )
continue;
dir.setFilter( QDir::NoDotAndDotDot );
while( !dir.isRoot() && dir.count() == 0 )
{
const QString name = dir.dirName();
dir.cdUp();
if( !dir.rmdir( name ) )
{
debug() << "Unable to remove " << name;
break;
}
}
}
}
m_tracksSuccessfullyTransferred.clear();
m_sourceTracks.clear();
this->deleteLater();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment