refactor: some random improvements
This commit is contained in:
parent
9899a0e098
commit
365cc198ba
@ -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);
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user