From ed44e16a669cc9572eaa32fd2cf8a73e690dc8f0 Mon Sep 17 00:00:00 2001 From: Craig Drummond Date: Sun, 10 Jun 2018 19:56:59 +0100 Subject: [PATCH] When moving foldes, move all recognized filetypes Closes #1305 --- devices/device.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/devices/device.cpp b/devices/device.cpp index d3527414e..b8051030f 100644 --- a/devices/device.cpp +++ b/devices/device.cpp @@ -64,30 +64,11 @@ void Device::moveDir(const QString &from, const QString &to, const QString &base QDir d(from); if (d.exists()) { QFileInfoList entries=d.entryInfoList(QDir::Files|QDir::NoSymLinks|QDir::Dirs|QDir::NoDotAndDotDot); - QList extraFiles; - QSet others=Covers::standardNames().toSet(); - others << coverFile << "albumart.pamp"; - if (!coverFile.isEmpty()) { - if (coverFile.endsWith(QLatin1String(".jpg"))) { - others << coverFile.left(coverFile.length()-4)+QLatin1String(".png"); - } else if (coverFile.endsWith(QLatin1String(".png"))) { - others << coverFile.left(coverFile.length()-4)+QLatin1String(".jpg"); - } - } + QSet fileTypes=QSet() << "jpg" << "png" << "pamp" << "txt" << "lyrics"; for (const QFileInfo &info: entries) { - if (info.isDir()) { - return; - } - if (!others.contains(info.fileName()) && !MPDConnection::isPlaylist(info.fileName())) { - return; - } - extraFiles.append(info.fileName()); - } - - for (const QString &f: extraFiles) { - if (!QFile::rename(from+'/'+f, to+'/'+f)) { - return; + if (!info.isDir() && (MPDConnection::isPlaylist(info.fileName()) || fileTypes.contains(info.suffix().toLower()))) { + QFile::rename(from+'/'+info.fileName(), to+'/'+info.fileName()); } } cleanDir(from, base, coverFile);