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);

View File

@ -110,7 +110,10 @@ void ImportPage::updateState()
// FIXME: actually do some validation of what's inside here... this is fake AF
QFileInfo fi(input);
// mrpack is a modrinth pack
if(fi.exists() && (fi.suffix() == "zip" || fi.suffix() == "mrpack"))
// Allow non-latin people to use ZIP files!
auto zip = QMimeDatabase().mimeTypeForUrl(url).suffixes().contains("zip");
if(fi.exists() && (zip || fi.suffix() == "mrpack"))
{
QFileInfo fi(url.fileName());
dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url));