diff options
author | TheKodeToad <TheKodeToad@proton.me> | 2023-03-28 14:22:28 +0100 |
---|---|---|
committer | TheKodeToad <TheKodeToad@proton.me> | 2023-03-28 14:22:28 +0100 |
commit | e42050cc8a2f74178d6cd0afe8c92ae9b802cf73 (patch) | |
tree | 99751241d422da79f8302e8c45e9b0fd50149e03 /launcher/modplatform | |
parent | 46f448dfba2a3c4bffe60f373ee27b1d19873c9e (diff) | |
download | PrismLauncher-e42050cc8a2f74178d6cd0afe8c92ae9b802cf73.tar.gz PrismLauncher-e42050cc8a2f74178d6cd0afe8c92ae9b802cf73.tar.bz2 PrismLauncher-e42050cc8a2f74178d6cd0afe8c92ae9b802cf73.zip |
Skip lookup if no files and fail if zipping fails
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher/modplatform')
-rw-r--r-- | launcher/modplatform/modrinth/ModrinthPackExportTask.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthPackExportTask.cpp b/launcher/modplatform/modrinth/ModrinthPackExportTask.cpp index 46bfab6d..d630f5d0 100644 --- a/launcher/modplatform/modrinth/ModrinthPackExportTask.cpp +++ b/launcher/modplatform/modrinth/ModrinthPackExportTask.cpp @@ -46,11 +46,15 @@ void ModrinthPackExportTask::executeTask() setProgress(0, 0); collectFiles(); - QByteArray* response = new QByteArray; - task = api.currentVersions(pendingHashes.values(), "sha512", response); - connect(task.get(), &NetJob::succeeded, [this, response]() { parseApiResponse(response); }); - connect(task.get(), &NetJob::failed, this, &ModrinthPackExportTask::emitFailed); - task->start(); + if (pendingHashes.isEmpty()) + buildZip(); + else { + QByteArray* response = new QByteArray; + task = api.currentVersions(pendingHashes.values(), "sha512", response); + connect(task.get(), &NetJob::succeeded, [this, response]() { parseApiResponse(response); }); + connect(task.get(), &NetJob::failed, this, &ModrinthPackExportTask::emitFailed); + task->start(); + } } bool ModrinthPackExportTask::abort() @@ -176,8 +180,12 @@ void ModrinthPackExportTask::buildZip() setProgress(i, files.length()); QString relative = mc.relativeFilePath(file.absoluteFilePath()); - if (!resolvedFiles.contains(relative) && !JlCompress::compressFile(&zip, file.absoluteFilePath(), "overrides/" + relative)) - qWarning() << "Could not compress" << file; + if (!resolvedFiles.contains(relative) && !JlCompress::compressFile(&zip, file.absoluteFilePath(), "overrides/" + relative)) { + QFile::remove(output); + QMetaObject::invokeMethod( + this, [this, relative]() { emitFailed(tr("Could not compress %1").arg(relative)); }, Qt::QueuedConnection); + return; + } i++; } |