FilesystemMusicStorage: QFile::moveToTrash recursively moves files to trash

This commit is contained in:
Jonas Kvinge
2022-12-27 20:59:09 +01:00
parent efa979ee03
commit fee63891ac
3 changed files with 1 additions and 33 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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);