Skip to content

Commit

Permalink
Don't recurse in subdirs when looking for covers.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcaliste committed Mar 14, 2024
1 parent fa06e7b commit 73b543a
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/datareader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <xmfile.h>


#include <QCryptographicHash>
#include <QDir>
#include <QDirIterator>
#include <QString>
Expand Down Expand Up @@ -211,23 +210,21 @@ void DataReader::readFile(QString file)
// if we have artist and album, we check for a cover image.
if (m_artist != "" && m_album != "") {
QFileInfo info(file);
QDirIterator iterator(info.dir().path(), QDirIterator::Subdirectories);
QDirIterator iterator(info.dir());
while (iterator.hasNext()) {
iterator.next();
// we are explicit about two common factors, the suffix `jpeg` (ToDo: add `jpg` and `png`
// we are explicit about two common factors, the type JPEG (ToDo: add PNG
// throughout all C++ source files, see issue #78), and basename cover or folder
if (iterator.fileInfo().isFile()) {
if ( iterator.fileInfo().suffix() == "jpeg" &&
// See ToDo above: (… || iterator.fileInfo().suffix() == "jpg" ||
if ( (iterator.fileInfo().suffix() == "jpeg" ||
iterator.fileInfo().suffix() == "jpg") &&
// See ToDo above: (… ||
// iterator.fileInfo().suffix() == "png") &&
(iterator.fileInfo().baseName() == "cover" ||
iterator.fileInfo().baseName() == "folder")
)
{
iterator.fileInfo().baseName() == "folder") ) {
QString th2 = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) +
"/media-art/album-" + doubleHash(m_artist, m_album) +
iterator.fileInfo().suffix();
qDebug() << "PROCESSING FILE: " << iterator.filePath();
"/media-art/album-" + doubleHash(m_artist, m_album) + ".jpeg";
qDebug() << "COPYING FILE ART: " << iterator.filePath() << m_artist << m_album;
QFile::copy(iterator.filePath(), th2);
}
}
Expand Down

0 comments on commit 73b543a

Please sign in to comment.