summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/metadatajob.cpp
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-12-12 16:52:08 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-12-16 11:42:46 +0200
commit77a90fdd09ad72f9919900e141cc9bfb8a533a12 (patch)
tree12c1ab61fdf600d79c00e8e73b5ae9d4357aaa53 /src/libs/installer/metadatajob.cpp
parentc02d33db5723b7605dc953de078c26d54f284d5e (diff)
Metadatajob: optimize checking for repository updates
The Updates.xml files from repositories may contain 'RepositoryUpdate' elements that list actions for existing or new repositories. We need to parse these updates and restart the metadata job if necessary. However this was done by parsing the XML file with the Qt XML modules QDom* classes, which gets expensive as not all of the files contain any repository updates. This is the most time consuming step left in case the cache is fully populated and up-to-date. Instead attempt to make the process faster by filtering out Updates.xml files that do not contain the 'RepositoryUpdate' element with a string search, before properly parsing the files. Change-Id: I87894fdc51f37095e46415a238c9da99624f4f44 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer/metadatajob.cpp')
-rw-r--r--src/libs/installer/metadatajob.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp
index 5a7aa66f4..33aabd268 100644
--- a/src/libs/installer/metadatajob.cpp
+++ b/src/libs/installer/metadatajob.cpp
@@ -862,13 +862,15 @@ MetadataJob::Status MetadataJob::refreshCacheItem(const FileTaskResult &result,
cachedMetadata->setPersistentRepositoryPath(repository.url());
// search for additional repositories that we might need to check
- QDomDocument doc = cachedMetadata->updatesDocument();
- const Status status = parseRepositoryUpdates(doc.documentElement(), result, cachedMetadata);
- if (status == XmlDownloadRetry) {
- // The repository update may have removed or replaced current repositories,
- // clear repository information from cached items and refresh on next fetch run.
- resetCacheRepositories();
- return status;
+ if (cachedMetadata->containsRepositoryUpdates()) {
+ QDomDocument doc = cachedMetadata->updatesDocument();
+ const Status status = parseRepositoryUpdates(doc.documentElement(), result, cachedMetadata);
+ if (status == XmlDownloadRetry) {
+ // The repository update may have removed or replaced current repositories,
+ // clear repository information from cached items and refresh on next fetch run.
+ resetCacheRepositories();
+ return status;
+ }
}
*refreshed = true;
return XmlDownloadSuccess;