refactor: some random improvements

This commit is contained in:
flow 2022-05-14 21:50:54 -03:00
parent 9899a0e098
commit 365cc198ba
No known key found for this signature in database
GPG key ID: 8D0F221F0A59F469
2 changed files with 8 additions and 5 deletions

View file

@ -504,16 +504,16 @@ void InstanceImportTask::processModrinth() {
QJsonObject hashes = Json::requireObject(obj, "hashes");
QString hash;
QCryptographicHash::Algorithm hashAlgorithm;
hash = Json::ensureString(hashes, "sha256");
hashAlgorithm = QCryptographicHash::Sha256;
hash = Json::ensureString(hashes, "sha1");
hashAlgorithm = QCryptographicHash::Sha1;
if (hash.isEmpty())
{
hash = Json::ensureString(hashes, "sha512");
hashAlgorithm = QCryptographicHash::Sha512;
if (hash.isEmpty())
{
hash = Json::ensureString(hashes, "sha1");
hashAlgorithm = QCryptographicHash::Sha1;
hash = Json::ensureString(hashes, "sha256");
hashAlgorithm = QCryptographicHash::Sha256;
if (hash.isEmpty())
{
throw JSONValidationError("No hash found for: " + file.path);