diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2023-02-22 14:24:05 +0200 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2023-04-25 09:30:31 +0300 |
commit | 3fbf3fee209587b03bdfe21d5bcccf800c78d97b (patch) | |
tree | 548f2248100b765027223a536a136baf9f334568 /src | |
parent | 22f2fc717d3f4f8f589c7d0fd28748ccc531bed0 (diff) |
Metadata cache: add warning for Updates.xml checksum mismatches
The vendor may provide information about expected checksum for a
repository Updates.xml file, so that installer does not download it
again if it is found in cache. If the expected checksum does not match
the checksum of the actually downloaded file, installer will try to
download it again and again for each metadata fetch.
Detect such mismatch and print a warning to catch those more easily.
Change-Id: I81d2e6e7c4f448229c35ab54c03bcfc3584f304d
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/metadatajob.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index b5883c66c..f90bfad9b 100644 --- a/src/libs/installer/metadatajob.cpp +++ b/src/libs/installer/metadatajob.cpp @@ -766,13 +766,21 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re return XmlDownloadFailure; } const FileTaskItem item = result.value(TaskRole::TaskItem).value<FileTaskItem>(); + const Repository repository = item.value(TaskRole::UserRole).value<Repository>(); - // Check if we have cached the metadata for this repository already QCryptographicHash hash(QCryptographicHash::Sha1); hash.addData(&file); const QByteArray updatesChecksum = hash.result().toHex(); + if (!repository.xmlChecksum().isEmpty() && updatesChecksum != repository.xmlChecksum()) { + qCWarning(lcDeveloperBuild).noquote().nospace() << "The checksum for Updates.xml " + "file downloaded from repository:\n" << repository.url().toString() << "\ndoes not " + "match the expected value:\n\tActual SHA1: " << updatesChecksum << "\n\tExpected SHA1: " + << repository.xmlChecksum() << Qt::endl; + } + bool refreshed; + // Check if we have cached the metadata for this repository already Status status = refreshCacheItem(result, updatesChecksum, &refreshed); if (status != XmlDownloadSuccess) return status; @@ -794,7 +802,7 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re } file.close(); - metadata->setRepository(item.value(TaskRole::UserRole).value<Repository>()); + metadata->setRepository(repository); const bool online = !(metadata->repository().url().scheme()).isEmpty(); bool testCheckSum = true; @@ -881,6 +889,7 @@ MetadataJob::Status MetadataJob::refreshCacheItem(const FileTaskResult &result, const FileTaskItem item = result.value(TaskRole::TaskItem).value<FileTaskItem>(); const Repository repository = item.value(TaskRole::UserRole).value<Repository>(); + if (cachedMetadata->isValid() && !repository.isCompressed()) { // Refresh repository information to cache. Same repository may appear in multiple // categories and the metadata may be available from default repositories simultaneously. |