Skip lookup if no files and fail if zipping fails
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
46f448dfba
commit
e42050cc8a
@ -46,12 +46,16 @@ void ModrinthPackExportTask::executeTask()
|
|||||||
setProgress(0, 0);
|
setProgress(0, 0);
|
||||||
collectFiles();
|
collectFiles();
|
||||||
|
|
||||||
|
if (pendingHashes.isEmpty())
|
||||||
|
buildZip();
|
||||||
|
else {
|
||||||
QByteArray* response = new QByteArray;
|
QByteArray* response = new QByteArray;
|
||||||
task = api.currentVersions(pendingHashes.values(), "sha512", response);
|
task = api.currentVersions(pendingHashes.values(), "sha512", response);
|
||||||
connect(task.get(), &NetJob::succeeded, [this, response]() { parseApiResponse(response); });
|
connect(task.get(), &NetJob::succeeded, [this, response]() { parseApiResponse(response); });
|
||||||
connect(task.get(), &NetJob::failed, this, &ModrinthPackExportTask::emitFailed);
|
connect(task.get(), &NetJob::failed, this, &ModrinthPackExportTask::emitFailed);
|
||||||
task->start();
|
task->start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ModrinthPackExportTask::abort()
|
bool ModrinthPackExportTask::abort()
|
||||||
{
|
{
|
||||||
@ -176,8 +180,12 @@ void ModrinthPackExportTask::buildZip()
|
|||||||
|
|
||||||
setProgress(i, files.length());
|
setProgress(i, files.length());
|
||||||
QString relative = mc.relativeFilePath(file.absoluteFilePath());
|
QString relative = mc.relativeFilePath(file.absoluteFilePath());
|
||||||
if (!resolvedFiles.contains(relative) && !JlCompress::compressFile(&zip, file.absoluteFilePath(), "overrides/" + relative))
|
if (!resolvedFiles.contains(relative) && !JlCompress::compressFile(&zip, file.absoluteFilePath(), "overrides/" + relative)) {
|
||||||
qWarning() << "Could not compress" << file;
|
QFile::remove(output);
|
||||||
|
QMetaObject::invokeMethod(
|
||||||
|
this, [this, relative]() { emitFailed(tr("Could not compress %1").arg(relative)); }, Qt::QueuedConnection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,12 +87,6 @@ void ExportMrPackDialog::done(int result)
|
|||||||
|
|
||||||
connect(&task, &Task::failed,
|
connect(&task, &Task::failed,
|
||||||
[this](const QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
|
[this](const QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
|
||||||
|
|
||||||
connect(&task, &Task::succeeded, [this, &task]() {
|
|
||||||
QStringList warnings = task.warnings();
|
|
||||||
if (warnings.count() > 0)
|
|
||||||
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
|
||||||
});
|
|
||||||
connect(&task, &Task::aborted, [this] {
|
connect(&task, &Task::aborted, [this] {
|
||||||
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)
|
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)
|
||||||
->show();
|
->show();
|
||||||
|
Loading…
Reference in New Issue
Block a user