FilesystemMusicStorage: QFile::moveToTrash recursively moves files to trash
This commit is contained in:
@@ -106,12 +106,7 @@ bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) {
|
||||
|
||||
if (job.use_trash_) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
if (fileInfo.isDir()) {
|
||||
return Utilities::MoveToTrashRecursive(path);
|
||||
}
|
||||
else {
|
||||
return QFile::moveToTrash(path);
|
||||
}
|
||||
return QFile::moveToTrash(path);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -239,32 +239,6 @@ quint64 FileSystemFreeSpace(const QString &path) {
|
||||
|
||||
}
|
||||
|
||||
bool MoveToTrashRecursive(const QString &path) {
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
QDir dir(path);
|
||||
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
|
||||
if (!MoveToTrashRecursive(path + "/" + child)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
|
||||
if (!QFile::moveToTrash(path + "/" + child)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return dir.rmdir(path);
|
||||
|
||||
#else
|
||||
Q_UNUSED(path)
|
||||
return false;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
bool RemoveRecursive(const QString &path) {
|
||||
|
||||
QDir dir(path);
|
||||
|
||||
@@ -65,7 +65,6 @@ QString ColorToRgba(const QColor &color);
|
||||
quint64 FileSystemCapacity(const QString &path);
|
||||
quint64 FileSystemFreeSpace(const QString &path);
|
||||
|
||||
bool MoveToTrashRecursive(const QString &path);
|
||||
bool RemoveRecursive(const QString &path);
|
||||
bool CopyRecursive(const QString &source, const QString &destination);
|
||||
bool Copy(QIODevice *source, QIODevice *destination);
|
||||
|
||||
Reference in New Issue
Block a user