mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-18 20:34:39 +01:00
Merge pull request #4303 from vkrishtal/issue_858
BugFix: clementine cannot delete directories in file tab. Fixes #858
This commit is contained in:
commit
a9abe4a4f0
@ -17,6 +17,7 @@
|
||||
|
||||
#include "filesystemmusicstorage.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/utilities.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@ -50,5 +51,10 @@ bool FilesystemMusicStorage::CopyToStorage(const CopyJob& job) {
|
||||
}
|
||||
|
||||
bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob& job) {
|
||||
return QFile::remove(job.metadata_.url().toLocalFile());
|
||||
}
|
||||
QString path = job.metadata_.url().toLocalFile();
|
||||
QFileInfo fileInfo(path);
|
||||
if (fileInfo.isDir())
|
||||
return Utilities::RemoveRecursive(path);
|
||||
else
|
||||
return QFile::remove(path);
|
||||
}
|
@ -219,17 +219,24 @@ QString GetTemporaryFileName() {
|
||||
return file;
|
||||
}
|
||||
|
||||
void RemoveRecursive(const QString& path) {
|
||||
bool RemoveRecursive(const QString& path) {
|
||||
QDir dir(path);
|
||||
for (const QString& child :
|
||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden))
|
||||
RemoveRecursive(path + "/" + child);
|
||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
|
||||
if (!RemoveRecursive(path + "/" + child))
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const QString& child :
|
||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden))
|
||||
QFile::remove(path + "/" + child);
|
||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
|
||||
if (!QFile::remove(path + "/" + child))
|
||||
return false;
|
||||
}
|
||||
|
||||
dir.rmdir(path);
|
||||
if (!dir.rmdir(path))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CopyRecursive(const QString& source, const QString& destination) {
|
||||
|
@ -51,7 +51,7 @@ quint64 FileSystemFreeSpace(const QString& path);
|
||||
|
||||
QString MakeTempDir(const QString template_name = QString());
|
||||
QString GetTemporaryFileName();
|
||||
void RemoveRecursive(const QString& path);
|
||||
bool RemoveRecursive(const QString& path);
|
||||
bool CopyRecursive(const QString& source, const QString& destination);
|
||||
bool Copy(QIODevice* source, QIODevice* destination);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user