Merge pull request #3203 from PrismLauncher/backport-3181-to-release-9.x

[Backport release-9.x] fix crash with invalid mrpack format
This commit is contained in:
Alexandru Ionut Tripon 2024-12-14 18:19:09 +02:00 committed by GitHub
commit a85720b8d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -261,12 +261,14 @@ bool ModrinthCreationTask::createInstance()
mod->setDetails(d); mod->setDetails(d);
mods[file.hash.toHex()] = mod; mods[file.hash.toHex()] = mod;
} }
if (file.downloads.empty()) {
setError(tr("The file '%1' is missing a download link. This is invalid in the pack format.").arg(fileName));
return false;
}
qDebug() << "Will try to download" << file.downloads.front() << "to" << file_path; qDebug() << "Will try to download" << file.downloads.front() << "to" << file_path;
auto dl = Net::ApiDownload::makeFile(file.downloads.dequeue(), file_path); auto dl = Net::ApiDownload::makeFile(file.downloads.dequeue(), file_path);
dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash)); dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));
downloadMods->addNetAction(dl); downloadMods->addNetAction(dl);
if (!file.downloads.empty()) { if (!file.downloads.empty()) {
// FIXME: This really needs to be put into a ConcurrentTask of // FIXME: This really needs to be put into a ConcurrentTask of
// MultipleOptionsTask's , once those exist :) // MultipleOptionsTask's , once those exist :)