summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/settings.cpp
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-08-24 12:19:11 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-10-14 15:15:51 +0300
commit59ce8c088fca01cfbabe9918302bdb0ee2eaf037 (patch)
tree0da452a18decd3f286fc2fda63307a7305891c39 /src/libs/installer/settings.cpp
parent30de0fe3f01ac3d6a0ee0a288d51dc920e4432ca (diff)
Add persistent metadata file cache
Introduce GenericDataCache and Metadata classes for storing the fetched metadata files (Updates.xml and uncompressed files from the meta.7z archives) on local filesystem. The cache uses a checksum based dictionary to keep track of the cached metadata items, with the SHA1 sums of downloaded Updates.xml files being the keys to refer single metadata item. We still need to download all the Updates.xml files on each fetch to check if the cached metadata items are applicable for the current repositories. Update the Updates.xml files in auto-test data to have unique contents, otherwise there could be conflicts with identical test repositories, as the tests will also utilize the cache now. Also omit registering Repository type to the meta-object system in the class contructors, this is expensive as we construct objects from the class frequently, in the worst case hundreds of thousands times. PackageManagerCore already does the registering. Task-number: QTIFW-2621 Change-Id: Iee10ead68befd722ffe7f18ca48483d5a3666658 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer/settings.cpp')
-rw-r--r--src/libs/installer/settings.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp
index 108d68832..df7d5f8cc 100644
--- a/src/libs/installer/settings.cpp
+++ b/src/libs/installer/settings.cpp
@@ -34,8 +34,11 @@
#include "globals.h"
#include "fileutils.h"
+#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QStringList>
+#include <QtCore/QStandardPaths>
+#include <QtCore/QUuid>
#include <QtGui/QFontMetrics>
#include <QtWidgets/QApplication>
@@ -76,6 +79,8 @@ static const QLatin1String scFtpProxy("FtpProxy");
static const QLatin1String scHttpProxy("HttpProxy");
static const QLatin1String scProxyType("ProxyType");
+static const QLatin1String scLocalCachePath("LocalCachePath");
+
const char scControlScript[] = "ControlScript";
template <typename T>
@@ -315,7 +320,7 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix,
<< scInstallerApplicationIcon << scInstallerWindowIcon
<< scLogo << scWatermark << scBanner << scBackground << scPageListPixmap
<< scStartMenuDir << scMaintenanceToolName << scMaintenanceToolIniFile << scMaintenanceToolAlias
- << scRemoveTargetDir
+ << scRemoveTargetDir << scLocalCacheDir << scPersistentLocalCache
<< scRunProgram << scRunProgramArguments << scRunProgramDescription
<< scDependsOnLocalInstallerBinary
<< scAllowSpaceInPath << scAllowNonAsciiCharacters << scDisableAuthorizationFallback
@@ -872,6 +877,40 @@ void Settings::setRepositorySettingsPageVisible(bool visible)
d->m_data.replace(scRepositorySettingsPageVisible, visible);
}
+bool Settings::persistentLocalCache() const
+{
+ return d->m_data.value(scPersistentLocalCache, true).toBool();
+}
+
+void Settings::setPersistentLocalCache(bool enable)
+{
+ d->m_data.replace(scPersistentLocalCache, enable);
+}
+
+QString Settings::localCacheDir() const
+{
+ const QString fallback = QLatin1String("qt-installer-framework") + QDir::separator()
+ + QUuid::createUuidV3(QUuid(), applicationName()).toString(QUuid::WithoutBraces);
+ return d->m_data.value(scLocalCacheDir, fallback).toString();
+}
+
+void Settings::setLocalCacheDir(const QString &dir)
+{
+ d->m_data.replace(scLocalCacheDir, dir);
+}
+
+QString Settings::localCachePath() const
+{
+ const QString fallback = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)
+ + QDir::separator() + localCacheDir();
+ return d->m_data.value(scLocalCachePath, fallback).toString();
+}
+
+void Settings::setLocalCachePath(const QString &path)
+{
+ d->m_data.replace(scLocalCachePath, path);
+}
+
Settings::ProxyType Settings::proxyType() const
{
return Settings::ProxyType(d->m_data.value(scProxyType, Settings::NoProxy).toInt());