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 "filesystemmusicstorage.h"
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
#include "core/utilities.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -50,5 +51,10 @@ 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());
|
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;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveRecursive(const QString& path) {
|
bool RemoveRecursive(const QString& path) {
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
for (const QString& child :
|
for (const QString& child :
|
||||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden))
|
dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
|
||||||
RemoveRecursive(path + "/" + child);
|
if (!RemoveRecursive(path + "/" + child))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (const QString& child :
|
for (const QString& child :
|
||||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden))
|
dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
|
||||||
QFile::remove(path + "/" + child);
|
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) {
|
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 MakeTempDir(const QString template_name = QString());
|
||||||
QString GetTemporaryFileName();
|
QString GetTemporaryFileName();
|
||||||
void RemoveRecursive(const QString& path);
|
bool RemoveRecursive(const QString& path);
|
||||||
bool CopyRecursive(const QString& source, const QString& destination);
|
bool CopyRecursive(const QString& source, const QString& destination);
|
||||||
bool Copy(QIODevice* source, QIODevice* destination);
|
bool Copy(QIODevice* source, QIODevice* destination);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user