diff options
author | Katja Marttila <[email protected]> | 2025-05-30 09:13:12 +0300 |
---|---|---|
committer | Katja Marttila <[email protected]> | 2025-06-04 09:05:17 +0300 |
commit | 1e033dde76b1ef17d71d318a98411dba0aaf3610 (patch) | |
tree | e4fe5479bdea522b62b99e451f3a8cefc8687f59 /src/libs | |
parent | a152d8e0fb9cd06dcb8f98d0d6e11cc14bac3dcf (diff) |
We should not rely that the repository format is the same when we
compare repositories when adding, replacing or removing repositories
using RepositoryUpdate. This bug occured when building IFW with Qt 6.9.
Also, when using Qt6.7, QUrl does not resolve relative paths correctly
if the repository path contains duplicate trailing slashes.
Task-number: QTIFW-3730
Change-Id: Id8c6dd3702e6af484c81c817dbf7f4e7bb973b63
Reviewed-by: Arttu Tarkiainen <[email protected]>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/installer/metadatajob.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/settings.cpp | 42 |
2 files changed, 34 insertions, 10 deletions
diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index 26fd2b2a5..d986db87d 100644 --- a/src/libs/installer/metadatajob.cpp +++ b/src/libs/installer/metadatajob.cpp @@ -260,7 +260,7 @@ void MetadataJob::doStart() continue; QString url; - url = repo.url().toString() + updateFilePath; + url = repo.url().toString(QUrl::StripTrailingSlash) + updateFilePath; if (!m_core->value(scUrlQueryString).isEmpty()) url += m_core->value(scUrlQueryString) + QLatin1Char('&'); // also append a random string to avoid proxy caches diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp index e18f63689..d3c74c41d 100644 --- a/src/libs/installer/settings.cpp +++ b/src/libs/installer/settings.cpp @@ -761,28 +761,52 @@ static bool apply(const RepoHash &updates, QMultiHash<QUrl, Repository> *reposTo QList<QPair<Repository, Repository> > values = updates.values(QLatin1String("replace")); for (int a = 0; a < values.count(); ++a) { const QPair<Repository, Repository> data = values.at(a); - if (reposToUpdate->contains(data.first.url())) { - update = true; - reposToUpdate->remove(data.first.url()); - reposToUpdate->insert(data.second.url(), data.second); + auto it = reposToUpdate->begin(); + while (it != reposToUpdate->end()) { + const QUrl &repoUrl = it.key(); + if (repoUrl.matches(data.first.url(), QUrl::NormalizePathSegments)) { + update = true; + reposToUpdate->remove(data.first.url()); + reposToUpdate->insert(data.second.url(), data.second); + break; + } else { + ++it; + } } } values = updates.values(QLatin1String("remove")); for (int a = 0; a < values.count(); ++a) { const QPair<Repository, Repository> data = values.at(a); - if (reposToUpdate->contains(data.first.url())) { - update = true; - reposToUpdate->remove(data.first.url()); + auto it = reposToUpdate->begin(); + while (it != reposToUpdate->end()) { + const QUrl &repoUrl = it.key(); + if (repoUrl.matches(data.first.url(), QUrl::NormalizePathSegments)) { + it = reposToUpdate->erase(it); + update = true; + } else { + ++it; + } } } values = updates.values(QLatin1String("add")); for (int a = 0; a < values.count(); ++a) { const QPair<Repository, Repository> data = values.at(a); - if (!reposToUpdate->contains(data.first.url())) { - update = true; + auto it = reposToUpdate->begin(); + bool repositoryAlreadyAdded = false; + while (it != reposToUpdate->end()) { + const QUrl &repoUrl = it.key(); + if (repoUrl.matches(data.first.url(), QUrl::NormalizePathSegments)) { + repositoryAlreadyAdded = true; + break; + } else { + ++it; + } + } + if (!repositoryAlreadyAdded) { reposToUpdate->insert(data.first.url(), data.first); + update = true; } } return update; |