mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-18 20:34:39 +01:00
BugFix: clementine cannot delete directories in file tab #858
This commit is contained in:
parent
b3ef8b0fe0
commit
69b4f9113a
@ -50,5 +50,44 @@ bool FilesystemMusicStorage::CopyToStorage(const CopyJob& job) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob& job) {
|
bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob& job) {
|
||||||
return QFile::remove(job.metadata_.url().toLocalFile());
|
bool result = false;
|
||||||
|
|
||||||
|
QString path = job.metadata_.url().toLocalFile();
|
||||||
|
QFileInfo fileInfo(path);
|
||||||
|
if (fileInfo.isDir())
|
||||||
|
result = RemoveDirectory(path);
|
||||||
|
else
|
||||||
|
result = QFile::remove(path);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FilesystemMusicStorage::RemoveDirectory(const QString& dirName) {
|
||||||
|
bool result = true;
|
||||||
|
QDir dir(dirName);
|
||||||
|
|
||||||
|
if (dir.exists(dirName)) {
|
||||||
|
auto fileInfoList = dir.entryInfoList(QDir::NoDotAndDotDot
|
||||||
|
| QDir::System
|
||||||
|
| QDir::Hidden
|
||||||
|
| QDir::AllDirs
|
||||||
|
| QDir::Files
|
||||||
|
, QDir::DirsFirst);
|
||||||
|
|
||||||
|
for (auto info : fileInfoList) {
|
||||||
|
// remove subdirectories too
|
||||||
|
if (info.isDir()) {
|
||||||
|
result = RemoveDirectory(info.absoluteFilePath());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = QFile::remove(info.absoluteFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = dir.rmdir(dirName);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ class FilesystemMusicStorage : public virtual MusicStorage {
|
|||||||
bool CopyToStorage(const CopyJob& job);
|
bool CopyToStorage(const CopyJob& job);
|
||||||
bool DeleteFromStorage(const DeleteJob& job);
|
bool DeleteFromStorage(const DeleteJob& job);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool RemoveDirectory(const QString &dirName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString root_;
|
QString root_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user