diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/genericdatacache.h | 2 | ||||
-rw-r--r-- | src/libs/installer/installer.pro | 2 | ||||
-rw-r--r-- | src/libs/installer/metadatacache.cpp | 67 | ||||
-rw-r--r-- | src/libs/installer/metadatacache.h | 46 | ||||
-rw-r--r-- | src/libs/installer/metadatajob.cpp | 5 | ||||
-rw-r--r-- | src/libs/installer/metadatajob.h | 4 | ||||
-rw-r--r-- | src/libs/installer/metadatajob_p.h | 6 |
7 files changed, 121 insertions, 11 deletions
diff --git a/src/libs/installer/genericdatacache.h b/src/libs/installer/genericdatacache.h index 5c1732334..94085502c 100644 --- a/src/libs/installer/genericdatacache.h +++ b/src/libs/installer/genericdatacache.h @@ -71,7 +71,7 @@ public: GenericDataCache(); explicit GenericDataCache(const QString &path, const QString &type, const QString &version); - ~GenericDataCache(); + virtual ~GenericDataCache(); void setType(const QString &type); void setVersion(const QString &version); diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro index 5a58968ee..30d15c695 100644 --- a/src/libs/installer/installer.pro +++ b/src/libs/installer/installer.pro @@ -52,6 +52,7 @@ HEADERS += packagemanagercore.h \ genericdatacache.h \ loggingutils.h \ metadata.h \ + metadatacache.h \ packagemanagercore_p.h \ packagemanagergui.h \ binaryformat.h \ @@ -158,6 +159,7 @@ SOURCES += packagemanagercore.cpp \ genericdatacache.cpp \ loggingutils.cpp \ metadata.cpp \ + metadatacache.cpp \ operationtracer.cpp \ packagemanagercore_p.cpp \ packagemanagergui.cpp \ diff --git a/src/libs/installer/metadatacache.cpp b/src/libs/installer/metadatacache.cpp new file mode 100644 index 000000000..744e455f4 --- /dev/null +++ b/src/libs/installer/metadatacache.cpp @@ -0,0 +1,67 @@ +/************************************************************************** +** +** Copyright (C) 2023 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#include "metadatacache.h" + +#define QUOTE_(x) #x +#define QUOTE(x) QUOTE_(x) + +namespace QInstaller { + +/*! + \inmodule QtInstallerFramework + \class QInstaller::MetadataCache + \brief The MetadataCache is a class for a checksum based storage of \c Metadata objects on disk. + + MetadataCache manages a cache storage for a set \l{path()}, which contains + a subdirectory for each registered \c Metadata item. The cache has a manifest file in + its root directory, which lists the version and type of the cache, and all its items. + The file is updated automatically when the metadata cache object is destructed, or + it can be updated periodically by calling \l{sync()}. +*/ + +/*! + Constructs a new empty cache. The cache is invalid until set with a + path and initialized. +*/ +MetadataCache::MetadataCache() + : GenericDataCache<Metadata>() +{ + setType(QLatin1String("Metadata")); + setVersion(QLatin1String(QUOTE(IFW_CACHE_FORMAT_VERSION))); +} + +/*! + Constructs a cache to \a path. The cache is initialized automatically. +*/ +MetadataCache::MetadataCache(const QString &path) + : GenericDataCache(path, QLatin1String("Metadata"), QLatin1String(QUOTE(IFW_CACHE_FORMAT_VERSION))) +{ +} + +} // namespace QInstaller diff --git a/src/libs/installer/metadatacache.h b/src/libs/installer/metadatacache.h new file mode 100644 index 000000000..804d1b6db --- /dev/null +++ b/src/libs/installer/metadatacache.h @@ -0,0 +1,46 @@ +/************************************************************************** +** +** Copyright (C) 2023 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#ifndef METADATACACHE_H +#define METADATACACHE_H + +#include "genericdatacache.h" +#include "metadata.h" + +namespace QInstaller { + +class MetadataCache : public GenericDataCache<Metadata> +{ +public: + MetadataCache(); + explicit MetadataCache(const QString &path); +}; + +} // namespace QInstaller + +#endif // METADATACACHE_H diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index 663b209f7..b5883c66c 100644 --- a/src/libs/installer/metadatajob.cpp +++ b/src/libs/installer/metadatajob.cpp @@ -42,9 +42,6 @@ #include <QtMath> #include <QRandomGenerator> -#define QUOTE_(x) #x -#define QUOTE(x) QUOTE_(x) - namespace QInstaller { /*! @@ -192,8 +189,6 @@ bool MetadataJob::resetCache(bool init) m_metaFromCache.clear(); m_metaFromCache.setPath(m_core->settings().localCachePath()); - m_metaFromCache.setType(QLatin1String("Metadata")); - m_metaFromCache.setVersion(QLatin1String(QUOTE(IFW_CACHE_FORMAT_VERSION))); if (!init) return true; diff --git a/src/libs/installer/metadatajob.h b/src/libs/installer/metadatajob.h index 37d9367e5..1dbb28773 100644 --- a/src/libs/installer/metadatajob.h +++ b/src/libs/installer/metadatajob.h @@ -33,7 +33,7 @@ #include "fileutils.h" #include "job.h" #include "metadata.h" -#include "genericdatacache.h" +#include "metadatacache.h" #include "repository.h" #include <QFutureWatcher> @@ -133,7 +133,7 @@ private: QSet<Repository> m_fetchedCategorizedRepositories; QHash<QString, Metadata *> m_fetchedMetadata; - GenericDataCache<Metadata> m_metaFromCache; + MetadataCache m_metaFromCache; }; } // namespace QInstaller diff --git a/src/libs/installer/metadatajob_p.h b/src/libs/installer/metadatajob_p.h index 8ab2d9e7d..0bd47b324 100644 --- a/src/libs/installer/metadatajob_p.h +++ b/src/libs/installer/metadatajob_p.h @@ -163,7 +163,7 @@ class UpdateCacheTask : public AbstractTask<void> Q_DISABLE_COPY(UpdateCacheTask) public: - UpdateCacheTask(GenericDataCache<Metadata> &cache, QHash<QString, Metadata *> &updates) + UpdateCacheTask(MetadataCache &cache, QHash<QString, Metadata *> &updates) : m_cache(&cache) , m_updates(&updates) {} @@ -177,7 +177,7 @@ public: QStringList registeredKeys; bool success = true; for (auto *meta : qAsConst(*m_updates)) { - if (!m_cache->registerItem(meta, true, GenericDataCache<Metadata>::Move)) { + if (!m_cache->registerItem(meta, true, MetadataCache::Move)) { success = false; break; } @@ -211,7 +211,7 @@ public: } private: - GenericDataCache<Metadata> *const m_cache; + MetadataCache *const m_cache; QHash<QString, Metadata *> *const m_updates; }; |