Commit e535ef7e authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

ensure that baloo detection works

Summary:
connect to the signal used to detect baloo earlier such that we detect
it correctly at start

Thanks to Martin Steigerwald for the report on stable branch (but also reproducible on master)

CCMAIL: martin@lichtvoll.de

BUG: 412210

Test Plan:
if no elisa files exist (database, kconfig and Qt settings) baloo is detected and used to get audio files

without it, nothing happen at start

Reviewers: #elisa, astippich, ngraham, jguidon

Reviewed By: #elisa, ngraham

Subscribers: mthw

Differential Revision: https://phabricator.kde.org/D24303
parent f9593770
......@@ -24,6 +24,8 @@
#include "trackslistener.h"
#include "qabstractitemmodeltester.h"
#include "config-upnp-qt.h"
#include <QtTest>
#include <QStandardItemModel>
#include <QStandardItem>
......@@ -6708,6 +6710,7 @@ void MediaPlayListTest::testEnqueueSampleFiles()
QCOMPARE(newTrackByNameInListSpy.count(), 0);
QCOMPARE(newEntryInListSpy.count(), 2);
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::TitleRole).toString(), QStringLiteral("Title"));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::AlbumRole).toString(), QStringLiteral("Test"));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ArtistRole).toString(), QStringLiteral("Artist"));
......@@ -6720,6 +6723,20 @@ void MediaPlayListTest::testEnqueueSampleFiles()
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::TrackNumberRole).toInt(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::DiscNumberRole).toInt(), 1);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::MilliSecondsDurationRole).toInt(), 1000);
#else
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::TitleRole).toString(), QStringLiteral("test.ogg"));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::AlbumRole).toString(), QStringLiteral(""));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::ArtistRole).toString(), QStringLiteral(""));
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::TrackNumberRole).toInt(), -1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::DiscNumberRole).toInt(), -1);
QCOMPARE(myPlayList.data(myPlayList.index(0, 0), MediaPlayList::MilliSecondsDurationRole).toInt(), 0);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::TitleRole).toString(), QStringLiteral("test2.ogg"));
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::AlbumRole).toString(), QStringLiteral(""));
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::ArtistRole).toString(), QStringLiteral(""));
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::TrackNumberRole).toInt(), -1);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::DiscNumberRole).toInt(), -1);
QCOMPARE(myPlayList.data(myPlayList.index(1, 0), MediaPlayList::MilliSecondsDurationRole).toInt(), 0);
#endif
}
void MediaPlayListTest::testEmptyEnqueue()
......
......@@ -39,7 +39,6 @@
#include <QSet>
#include <QPair>
#include <QAtomicInt>
#include <QDebug>
#include <QtGlobal>
......@@ -248,6 +247,8 @@ void AbstractFileListing::scanDirectory(QList<MusicAudioTrack> &newFiles, const
emitNewFiles(newFiles);
newFiles.clear();
}
} else {
qCDebug(orgKdeElisaIndexer()) << "AbstractFileListing::scanDirectory" << newFilePath << "is not a valid track";
}
if (d->mStopRequest == 1) {
......@@ -376,6 +377,8 @@ void AbstractFileListing::scanDirectoryTree(const QString &path)
{
auto newFiles = QList<MusicAudioTrack>();
qCDebug(orgKdeElisaIndexer()) << "AbstractFileListing::scanDirectoryTree" << path;
scanDirectory(newFiles, QUrl::fromLocalFile(path));
if (!newFiles.isEmpty() && d->mStopRequest == 0) {
......@@ -463,6 +466,8 @@ void AbstractFileListing::checkFilesToRemove()
allRemovedFiles.push_back(itFile.key());
}
qCDebug(orgKdeElisaIndexer()) << "AbstractFileListing::checkFilesToRemove" << allRemovedFiles.size();
if (!allRemovedFiles.isEmpty()) {
setWaitEndTrackRemoval(true);
Q_EMIT removedTracksList(allRemovedFiles);
......@@ -484,6 +489,8 @@ bool AbstractFileListing::checkEmbeddedCoverImage(const QString &localFileName)
return true;
}
}
#else
Q_UNUSED(localFileName)
#endif
return false;
......
......@@ -350,7 +350,7 @@ void LocalBalooFileListing::triggerRefreshOfContent()
if (!scanFileInfo.exists()) {
qCDebug(orgKdeElisaBaloo()) << "LocalBalooFileListing::triggerRefreshOfContent" << fileName << "file does not exists";
return;
continue;
}
auto itExistingFile = allFiles().find(newFileUrl);
......
......@@ -5531,9 +5531,12 @@ void DatabaseInterface::updateTrackOrigin(const QUrl &fileName, const QDateTime
qulonglong DatabaseInterface::internalInsertTrack(const MusicAudioTrack &oneTrack,
const QHash<QString, QUrl> &covers, bool &isInserted)
{
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack trying to insert" << oneTrack;
qulonglong resultId = 0;
if (oneTrack.title().isEmpty()) {
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << oneTrack << "is not inserted";
return resultId;
}
......@@ -5705,6 +5708,7 @@ qulonglong DatabaseInterface::internalInsertTrack(const MusicAudioTrack &oneTrac
d->mInsertTrackQuery.bindValue(QStringLiteral(":hasEmbeddedCover"), oneTrack.hasEmbeddedCover());
auto result = execQuery(d->mInsertTrackQuery);
qCDebug(orgKdeElisaDatabase) << "DatabaseInterface::internalInsertTrack" << oneTrack << "is inserted";
if (result && d->mInsertTrackQuery.isActive()) {
d->mInsertTrackQuery.finish();
......
......@@ -19,6 +19,8 @@
#include "musicaudiotrack.h"
#include "abstractfile/indexercommon.h"
#include <QThread>
#include <QHash>
#include <QFileInfo>
......@@ -46,6 +48,7 @@ LocalFileListing::~LocalFileListing()
void LocalFileListing::executeInit(QHash<QUrl, QDateTime> allFiles)
{
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::executeInit" << "with" << allFiles.size() << "files";
AbstractFileListing::executeInit(std::move(allFiles));
}
......@@ -53,6 +56,8 @@ void LocalFileListing::triggerRefreshOfContent()
{
Q_EMIT indexingStarted();
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::triggerRefreshOfContent" << allRootPaths();
AbstractFileListing::triggerRefreshOfContent();
const auto &rootPaths = allRootPaths();
......
......@@ -19,6 +19,8 @@
#include "config-upnp-qt.h"
#include "abstractfile/indexercommon.h"
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
#include <KFileMetaData/ExtractorCollection>
......@@ -35,6 +37,7 @@
#endif
#include <QLoggingCategory>
#include <QFileInfo>
#include <QLocale>
......@@ -60,7 +63,6 @@ FileScanner::~FileScanner() = default;
MusicAudioTrack FileScanner::scanOneFile(const QUrl &scanFile, const QMimeDatabase &mimeDatabase)
{
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
MusicAudioTrack newTrack;
auto localFileName = scanFile.toLocalFile();
......@@ -68,7 +70,9 @@ MusicAudioTrack FileScanner::scanOneFile(const QUrl &scanFile, const QMimeDataba
QFileInfo scanFileInfo(localFileName);
newTrack.setFileModificationTime(scanFileInfo.fileTime(QFile::FileModificationTime));
newTrack.setResourceURI(scanFile);
newTrack.setRating(0);
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
const auto &fileMimeType = mimeDatabase.mimeTypeForFile(localFileName);
if (!fileMimeType.name().startsWith(QStringLiteral("audio/"))) {
return newTrack;
......@@ -92,13 +96,17 @@ MusicAudioTrack FileScanner::scanOneFile(const QUrl &scanFile, const QMimeDataba
scanProperties(localFileName, newTrack);
return newTrack;
qCDebug(orgKdeElisaIndexer()) << "scanOneFile" << scanFile << "using KFileMetaData" << newTrack;
#else
Q_UNUSED(scanFile)
Q_UNUSED(mimeDatabase)
return {};
newTrack.setTitle(scanFileInfo.fileName());
newTrack.setValid(true);
qCDebug(orgKdeElisaIndexer()) << "scanOneFile" << scanFile << "no metadata provider" << newTrack;
#endif
return newTrack;
}
void FileScanner::scanProperties(const Baloo::File &match, MusicAudioTrack &trackData)
......@@ -106,9 +114,13 @@ void FileScanner::scanProperties(const Baloo::File &match, MusicAudioTrack &trac
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
d->mAllProperties = match.properties();
scanProperties(match.path(), trackData);
qCDebug(orgKdeElisaIndexer()) << "scanProperties" << match.path() << "using Baloo" << trackData;
#else
Q_UNUSED(match)
Q_UNUSED(trackData)
qCDebug(orgKdeElisaIndexer()) << "scanProperties" << "no metadata provider" << trackData;
#endif
}
......
......@@ -124,6 +124,15 @@ MusicListenersManager::MusicListenersManager(QObject *parent)
connect(&d->mDatabaseInterface, &DatabaseInterface::cleanedDatabase,
this, &MusicListenersManager::cleanedDatabase);
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
connect(&d->mBalooDetector, &BalooDetector::balooAvailabilityChanged,
this, &MusicListenersManager::balooAvailabilityChanged);
#endif
qCInfo(orgKdeElisaIndexersManager) << "Local file system indexer is inactive";
qCInfo(orgKdeElisaIndexersManager) << "Baloo indexer is unavailable";
qCInfo(orgKdeElisaIndexersManager) << "Baloo indexer is inactive";
const auto &localDataPaths = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
auto databaseFileName = QString();
if (!localDataPaths.isEmpty()) {
......@@ -159,15 +168,6 @@ MusicListenersManager::MusicListenersManager(QObject *parent)
connect(&d->mDatabaseInterface, &DatabaseInterface::tracksAdded,
this, &MusicListenersManager::increaseImportedTracksCount);
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
connect(&d->mBalooDetector, &BalooDetector::balooAvailabilityChanged,
this, &MusicListenersManager::balooAvailabilityChanged);
#endif
qCInfo(orgKdeElisaIndexersManager) << "Local file system indexer is inactive";
qCInfo(orgKdeElisaIndexersManager) << "Baloo indexer is unavailable";
qCInfo(orgKdeElisaIndexersManager) << "Baloo indexer is inactive";
}
MusicListenersManager::~MusicListenersManager()
......@@ -306,14 +306,6 @@ void MusicListenersManager::configChanged()
if (!d->mBalooIndexerActive && !d->mFileSystemIndexerActive) {
testBalooIndexerAvailability();
} else {
if (d->mBalooIndexerActive) {
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
QMetaObject::invokeMethod(d->mBalooListener.fileListing(), "init", Qt::QueuedConnection);
#endif
} else if (d->mFileSystemIndexerActive) {
QMetaObject::invokeMethod(d->mFileListener.fileListing(), "init", Qt::QueuedConnection);
}
}
#if defined UPNPQT_FOUND && UPNPQT_FOUND
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment