Changeset View
Changeset View
Standalone View
Standalone View
src/core/engine.cpp
Show First 20 Lines • Show All 710 Lines • ▼ Show 20 Line(s) | 707 | for (const QSharedPointer<KNSCore::Provider> &p : qAsConst(m_providers)) { | |||
---|---|---|---|---|---|
711 | p->loadEntries(request); | 711 | p->loadEntries(request); | ||
712 | } | 712 | } | ||
713 | } | 713 | } | ||
714 | 714 | | |||
715 | /** | 715 | /** | ||
716 | * we look for the directory where all the resources got installed. | 716 | * we look for the directory where all the resources got installed. | ||
717 | * assuming it was extracted into a directory | 717 | * assuming it was extracted into a directory | ||
718 | */ | 718 | */ | ||
719 | static QDir sharedDir(QStringList dirs, const QString &rootPath) | 719 | static QDir sharedDir(QStringList dirs, QString rootPath) | ||
720 | { | 720 | { | ||
721 | // Ensure that rootPath definitely is a clean path with a slash at the end | ||||
722 | rootPath = QDir::cleanPath(rootPath) + QStringLiteral("/"); | ||||
723 | qCInfo(KNEWSTUFFCORE) << Q_FUNC_INFO << dirs << rootPath; | ||||
721 | while(!dirs.isEmpty()) { | 724 | while(!dirs.isEmpty()) { | ||
722 | const QString currentPath = QDir::cleanPath(dirs.takeLast()); | 725 | QString thisDir(dirs.takeLast()); | ||
723 | if (!currentPath.startsWith(rootPath)) | 726 | if (thisDir.endsWith(QStringLiteral("*"))) { | ||
727 | qCInfo(KNEWSTUFFCORE) << "Directory entry" << thisDir << "ends in a *, indicating this was installed from an archive - see Installation::archiveEntries"; | ||||
728 | thisDir.chop(1); | ||||
729 | } | ||||
730 | | ||||
731 | const QString currentPath = QDir::cleanPath(thisDir); | ||||
732 | qCInfo(KNEWSTUFFCORE) << "Current path is" << currentPath; | ||||
733 | if (!currentPath.startsWith(rootPath)) { | ||||
734 | qCInfo(KNEWSTUFFCORE) << "Current path" << currentPath << "does not start with" << rootPath << "and should be ignored"; | ||||
724 | continue; | 735 | continue; | ||
736 | } | ||||
725 | 737 | | |||
726 | const QFileInfo current(currentPath); | 738 | const QFileInfo current(currentPath); | ||
727 | if (!current.isDir()) | 739 | qCInfo(KNEWSTUFFCORE) << "Current file info is" << current; | ||
740 | if (!current.isDir()) { | ||||
741 | qCInfo(KNEWSTUFFCORE) << "Current path" << currentPath << "is not a directory, and should be ignored"; | ||||
728 | continue; | 742 | continue; | ||
743 | } | ||||
729 | 744 | | |||
730 | const QDir dir = current.dir(); | 745 | const QDir dir(currentPath); | ||
731 | if (dir.path()==(rootPath+dir.dirName())) { | 746 | if (dir.path()==(rootPath+dir.dirName())) { | ||
747 | qCDebug(KNEWSTUFFCORE) << "Found directory" << dir; | ||||
apol: Shouldn't we make sure rootPath ends with /?
at least with an ASSERT if we know it's there. | |||||
Hmm... It /should/ be done, but it's also not a bad thing to perform a touch of sanitising on this, so... yup, let's just do that, update incoming leinir: Hmm... It /should/ be done, but it's also not a bad thing to perform a touch of sanitising on… | |||||
732 | return dir; | 748 | return dir; | ||
733 | } | 749 | } | ||
734 | } | 750 | } | ||
751 | qCWarning(KNEWSTUFFCORE) << "Failed to locate any shared installed directory in" << dirs << "and this is almost certainly very bad."; | ||||
735 | return {}; | 752 | return {}; | ||
736 | } | 753 | } | ||
737 | 754 | | |||
738 | QString Engine::adoptionCommand(const KNSCore::EntryInternal& entry) const | 755 | QString Engine::adoptionCommand(const KNSCore::EntryInternal& entry) const | ||
739 | { | 756 | { | ||
740 | auto adoption = m_adoptionCommand; | 757 | auto adoption = m_adoptionCommand; | ||
741 | if(adoption.isEmpty()) | 758 | if(adoption.isEmpty()) | ||
742 | return {}; | 759 | return {}; | ||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |
Shouldn't we make sure rootPath ends with /?
at least with an ASSERT if we know it's there.