From 476b6d6fffaf6841adaf68889e8b8ddae17dd382 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Wed, 28 Dec 2022 11:19:31 +0200 Subject: Resolve downloadable archive list while installing Installer can have thousands of components and only few of them user selects for install. Parsing the downloadable archives to install only when they are selected for install for better performance. Task-number: QTIFW-2805 Change-Id: I0771df05e17c85f37639768e2581d85bbf7bf66f Reviewed-by: Arttu Tarkiainen --- src/libs/installer/component.cpp | 17 ++++++++++++++++- src/libs/installer/component.h | 3 ++- src/libs/installer/component_p.h | 1 + src/libs/installer/packagemanagercore.cpp | 10 ++-------- 4 files changed, 21 insertions(+), 10 deletions(-) (limited to 'src/libs') diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 78cbba79f..ccf9dc8bb 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -993,6 +993,15 @@ void Component::addDownloadableArchive(const QString &path) d->m_downloadableArchives.append(d->m_vars.value(scVersion) + path); } +/*! + \internal +*/ +void Component::addDownloadableArchives(const QString& archives) +{ + Q_ASSERT(isFromOnlineRepository()); + d->m_downloadableArchivesVariable = archives; +} + /*! Removes the archive \a path previously added via addDownloadableArchive() from this component. This can only be called if this component was downloaded from an online repository. @@ -1008,9 +1017,15 @@ void Component::removeDownloadableArchive(const QString &path) /*! Returns the archives to be downloaded from the online repository before installation. + Should be called only once when the installation starts. */ -QStringList Component::downloadableArchives() const +QStringList Component::downloadableArchives() { + const QStringList downloadableArchives = d->m_downloadableArchivesVariable + .split(QInstaller::commaRegExp(), Qt::SkipEmptyParts); + foreach (const QString downloadableArchive, downloadableArchives) + addDownloadableArchive(downloadableArchive); + return d->m_downloadableArchives; } diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h index 8092b4c37..0d8bf85ab 100644 --- a/src/libs/installer/component.h +++ b/src/libs/installer/component.h @@ -150,9 +150,10 @@ public: Q_INVOKABLE bool addElevatedOperation(QQmlV4Function *args); bool addElevatedOperation(const QString &operation, const QStringList ¶meters); - QStringList downloadableArchives() const; + QStringList downloadableArchives(); Q_INVOKABLE void addDownloadableArchive(const QString &path); Q_INVOKABLE void removeDownloadableArchive(const QString &path); + void addDownloadableArchives(const QString& archives); QStringList stopProcessForUpdateRequests() const; Q_INVOKABLE void addStopProcessForUpdateRequest(const QString &process); diff --git a/src/libs/installer/component_p.h b/src/libs/installer/component_p.h index fe9d84023..dea2d4935 100644 --- a/src/libs/installer/component_p.h +++ b/src/libs/installer/component_p.h @@ -75,6 +75,7 @@ public: QList m_childComponents; QList m_allChildComponents; QStringList m_downloadableArchives; + QString m_downloadableArchivesVariable; QStringList m_stopProcessForUpdateRequests; QHash > m_userInterfaces; QHash m_scriptHash; diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 642f13b03..8c70bdae6 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -3977,14 +3977,8 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo component->setValue(QLatin1String("password"), repo.password()); } - // add downloadable archive from xml - const QStringList downloadableArchives = data.package->data(scDownloadableArchives).toString() - .split(QInstaller::commaRegExp(), Qt::SkipEmptyParts); - - if (component->isFromOnlineRepository()) { - foreach (const QString downloadableArchive, downloadableArchives) - component->addDownloadableArchive(downloadableArchive); - } + if (component->isFromOnlineRepository()) + component->addDownloadableArchives(data.package->data(scDownloadableArchives).toString()); const QStringList componentsToReplace = data.package->data(scReplaces).toString() .split(QInstaller::commaRegExp(), Qt::SkipEmptyParts); -- cgit v1.2.3