diff --git a/src/kpackage/package.cpp b/src/kpackage/package.cpp --- a/src/kpackage/package.cpp +++ b/src/kpackage/package.cpp @@ -42,6 +42,7 @@ #include "private/package_p.h" //#include "private/packages_p.h" #include "private/packagejob_p.h" +#include "private/packageloader_p.h" namespace KPackage { @@ -816,6 +817,7 @@ { const QString src = sourcePackage; QString dest = packageRoot.isEmpty() ? defaultPackageRoot() : packageRoot; + KPackage::PackageLoader::self()->d->maxCacheAge = -1; //use absolute paths if passed, otherwise go under share if (!QDir::isAbsolutePath(dest)) { @@ -835,6 +837,7 @@ { const QString src = sourcePackage; QString dest = packageRoot.isEmpty() ? defaultPackageRoot() : packageRoot; + KPackage::PackageLoader::self()->d->maxCacheAge = -1; //use absolute paths if passed, otherwise go under share if (!QDir::isAbsolutePath(dest)) { @@ -852,6 +855,7 @@ KJob *Package::uninstall(const QString &packageName, const QString &packageRoot) { + KPackage::PackageLoader::self()->d->maxCacheAge = -1; d->createPackageMetadata(packageRoot + QLatin1Char('/') + packageName); if (!d->structure) { return nullptr; diff --git a/src/kpackage/packageloader.h b/src/kpackage/packageloader.h --- a/src/kpackage/packageloader.h +++ b/src/kpackage/packageloader.h @@ -131,6 +131,7 @@ virtual ~PackageLoader(); private: + friend class Package; PackageLoaderPrivate *const d; Q_DISABLE_COPY(PackageLoader) }; diff --git a/src/kpackage/packageloader.cpp b/src/kpackage/packageloader.cpp --- a/src/kpackage/packageloader.cpp +++ b/src/kpackage/packageloader.cpp @@ -18,6 +18,7 @@ */ #include "packageloader.h" +#include "private/packageloader_p.h" #include #include @@ -46,34 +47,6 @@ static PackageLoader *s_packageTrader = nullptr; -class PackageLoaderPrivate -{ -public: - PackageLoaderPrivate() - : isDefaultLoader(false), - packageStructurePluginDir(QStringLiteral("kpackage/packagestructure")) - { - } - - static QSet knownCategories(); - static QString parentAppConstraint(const QString &parentApp = QString()); - - static QSet s_customCategories; - - QHash > structures; - bool isDefaultLoader; - QString packageStructurePluginDir; - // We only use this cache during start of the process to speed up many consecutive calls - // After that, we're too afraid to produce race conditions and it's not that time-critical anyway - // the 20 seconds here means that the cache is only used within 20sec during startup, after that, - // complexity goes up and we'd have to update the cache in order to avoid subtle bugs - // just not using the cache is way easier then, since it doesn't make *that* much of a difference, - // anyway - int maxCacheAge = 20; - qint64 pluginCacheAge = 0; - QHash> pluginCache; -}; - QSet PackageLoaderPrivate::s_customCategories; QSet PackageLoaderPrivate::knownCategories() diff --git a/src/kpackage/private/packageloader_p.h b/src/kpackage/private/packageloader_p.h new file mode 100644 --- /dev/null +++ b/src/kpackage/private/packageloader_p.h @@ -0,0 +1,60 @@ +/* + * Copyright 2010 Ryan Rix + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KPACKAGE_PACKAGELOADER_P_H +#define KPACKAGE_PACKAGELOADER_P_H + +#include "packagestructure.h" +#include + +namespace KPackage +{ + +class PackageLoaderPrivate +{ +public: + PackageLoaderPrivate() + : isDefaultLoader(false), + packageStructurePluginDir(QStringLiteral("kpackage/packagestructure")) + { + } + + static QSet knownCategories(); + static QString parentAppConstraint(const QString &parentApp = QString()); + + static QSet s_customCategories; + + QHash > structures; + bool isDefaultLoader; + QString packageStructurePluginDir; + // We only use this cache during start of the process to speed up many consecutive calls + // After that, we're too afraid to produce race conditions and it's not that time-critical anyway + // the 20 seconds here means that the cache is only used within 20sec during startup, after that, + // complexity goes up and we'd have to update the cache in order to avoid subtle bugs + // just not using the cache is way easier then, since it doesn't make *that* much of a difference, + // anyway + int maxCacheAge = 20; + qint64 pluginCacheAge = 0; + QHash> pluginCache; +}; + +} + +#endif +