mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-07-08 13:08:29 +02:00
change: improve checksum mismatch logging
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
8a68c625fb
commit
3ee45691ab
3 changed files with 9 additions and 7 deletions
|
|
@ -127,9 +127,11 @@ void BaseEntityLoadTask::executeTask()
|
||||||
}
|
}
|
||||||
|
|
||||||
// on online the hash needs to match
|
// on online the hash needs to match
|
||||||
hashMatches = m_entity->m_sha256 == m_entity->m_file_sha256;
|
const auto& expected = m_entity->m_sha256;
|
||||||
|
const auto& actual = m_entity->m_file_sha256;
|
||||||
|
hashMatches = expected == actual;
|
||||||
if (m_mode == Net::Mode::Online && !m_entity->m_sha256.isEmpty() && !hashMatches) {
|
if (m_mode == Net::Mode::Online && !m_entity->m_sha256.isEmpty() && !hashMatches) {
|
||||||
throw Exception("mismatched checksum");
|
throw Exception(QString("Checksum mismatch, expected sha256: %1, got: %2").arg(expected, actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
// load local file
|
// load local file
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ QList<Net::NetRequest::Ptr> Library::getDownloads(const RuntimeContext& runtimeC
|
||||||
if (sha1.size()) {
|
if (sha1.size()) {
|
||||||
auto dl = Net::ApiDownload::makeCached(url, entry, options);
|
auto dl = Net::ApiDownload::makeCached(url, entry, options);
|
||||||
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, sha1));
|
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, sha1));
|
||||||
qDebug() << "Checksummed Download for:" << rawName().serialize() << "storage:" << storage << "url:" << url;
|
qDebug() << "Checksummed Download for:" << rawName().serialize() << "storage:" << storage << "url:" << url << "expected sha1:" << sha1;
|
||||||
out.append(dl);
|
out.append(dl);
|
||||||
} else {
|
} else {
|
||||||
out.append(Net::ApiDownload::makeCached(url, entry, options));
|
out.append(Net::ApiDownload::makeCached(url, entry, options));
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
#include "Validator.h"
|
#include "Validator.h"
|
||||||
|
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QFile>
|
|
||||||
|
|
||||||
namespace Net {
|
namespace Net {
|
||||||
class ChecksumValidator : public Validator {
|
class ChecksumValidator : public Validator {
|
||||||
|
|
@ -69,10 +68,11 @@ class ChecksumValidator : public Validator {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto validate(QNetworkReply&) -> bool override
|
auto validate(QNetworkReply& reply) -> bool override
|
||||||
{
|
{
|
||||||
if (m_expected.size() && m_expected != hash()) {
|
if (!m_expected.isEmpty() && m_expected != hash()) {
|
||||||
qWarning() << "Checksum mismatch, download is bad.";
|
qWarning() << "Checksum mismatch for URL:" << reply.url().toString() << "expected:" << m_expected << "got:" << hash()
|
||||||
|
<< "algorithm:" << m_checksum.algorithm();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue