Commit 10e1201a authored by Matthieu Gallien's avatar Matthieu Gallien

Merge branch 'fixIndexingOnWindows' into 'release/19.12'

properly get the path in the kcm module and use it cleanly in indexers

See merge request !39
parents 519b2153 674d0ff4
......@@ -89,12 +89,16 @@ void KCMElisaLocalFile::setRootPath(QStringList rootPath)
mRootPath.clear();
for (const auto &onePath : rootPath) {
if (onePath.startsWith(QLatin1String("file:///"))) {
mRootPath.push_back(onePath.mid(7));
} else if (onePath.startsWith(QLatin1String("file:/"))) {
mRootPath.push_back(onePath.mid(5));
} else {
mRootPath.push_back(onePath);
auto workPath = onePath;
if (workPath.startsWith(QLatin1String("file:/"))) {
auto urlPath = QUrl{workPath};
workPath = urlPath.toLocalFile();
}
QFileInfo pathFileInfo(workPath);
auto directoryPath = pathFileInfo.canonicalFilePath();
if (!directoryPath.isEmpty()) {
mRootPath.push_back(directoryPath);
}
}
......
......@@ -217,17 +217,25 @@ bool MusicListenersManager::androidIndexerAvailable() const
return d->mAndroidIndexerAvailable;
}
auto MusicListenersManager::initializeRootPath()
{
auto initialRootPath = QStringList{};
auto systemMusicPaths = QStandardPaths::standardLocations(QStandardPaths::MusicLocation);
for (const auto &musicPath : qAsConst(systemMusicPaths)) {
initialRootPath.push_back(musicPath);
}
Elisa::ElisaConfiguration::setRootPath(initialRootPath);
Elisa::ElisaConfiguration::self()->save();
return initialRootPath;
}
void MusicListenersManager::databaseReady()
{
auto initialRootPath = Elisa::ElisaConfiguration::rootPath();
if (initialRootPath.isEmpty()) {
auto systemMusicPaths = QStandardPaths::standardLocations(QStandardPaths::MusicLocation);
for (const auto &musicPath : qAsConst(systemMusicPaths)) {
initialRootPath.push_back(musicPath);
}
Elisa::ElisaConfiguration::setRootPath(initialRootPath);
Elisa::ElisaConfiguration::self()->save();
initializeRootPath();
}
d->mConfigFileWatcher.addPath(Elisa::ElisaConfiguration::self()->config()->name());
......@@ -321,12 +329,26 @@ void MusicListenersManager::configChanged()
//resolve symlinks
QStringList allRootPaths;
for (const auto &path : currentConfiguration->rootPath()) {
QFileInfo pathFileInfo(path);
for (const auto &onePath : currentConfiguration->rootPath()) {
auto workPath = onePath;
if (workPath.startsWith(QLatin1String("file:/"))) {
auto urlPath = QUrl{workPath};
workPath = urlPath.toLocalFile();
}
QFileInfo pathFileInfo(workPath);
auto directoryPath = pathFileInfo.canonicalFilePath();
//directory must always end with a slash
directoryPath.append(QLatin1Char('/'));
allRootPaths << directoryPath;
if (!directoryPath.isEmpty()) {
if (directoryPath.rightRef(1) != QLatin1Char('/'))
{
directoryPath.append(QLatin1Char('/'));
}
allRootPaths.push_back(directoryPath);
}
}
if (allRootPaths.isEmpty()) {
allRootPaths = initializeRootPath();
}
d->mFileListener.setAllRootPaths(allRootPaths);
......
......@@ -183,6 +183,8 @@ private:
void startBalooIndexing();
auto initializeRootPath();
std::unique_ptr<MusicListenersManagerPrivate> d;
void createTracksListener();
......
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