Fixed curseforge export

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
(cherry picked from commit a5b059ebad)
This commit is contained in:
Trial97 2024-04-29 00:27:15 +03:00 committed by github-actions[bot]
parent 87354d9a7d
commit 119ee7a5b4
4 changed files with 22 additions and 11 deletions

View File

@ -154,7 +154,12 @@ bool collectFileListRecursively(const QString& rootDir, const QString& subDir, Q
#if defined(LAUNCHER_APPLICATION) #if defined(LAUNCHER_APPLICATION)
class ExportToZipTask : public Task { class ExportToZipTask : public Task {
public: public:
ExportToZipTask(QString outputPath, QDir dir, QFileInfoList files, QString destinationPrefix = "", bool followSymlinks = false) ExportToZipTask(QString outputPath,
QDir dir,
QFileInfoList files,
QString destinationPrefix = "",
bool followSymlinks = false,
bool utf8Enabled = false)
: m_output_path(outputPath) : m_output_path(outputPath)
, m_output(outputPath) , m_output(outputPath)
, m_dir(dir) , m_dir(dir)
@ -163,10 +168,15 @@ class ExportToZipTask : public Task {
, m_follow_symlinks(followSymlinks) , m_follow_symlinks(followSymlinks)
{ {
setAbortable(true); setAbortable(true);
m_output.setUtf8Enabled(true); m_output.setUtf8Enabled(utf8Enabled);
}; };
ExportToZipTask(QString outputPath, QString dir, QFileInfoList files, QString destinationPrefix = "", bool followSymlinks = false) ExportToZipTask(QString outputPath,
: ExportToZipTask(outputPath, QDir(dir), files, destinationPrefix, followSymlinks){}; QString dir,
QFileInfoList files,
QString destinationPrefix = "",
bool followSymlinks = false,
bool utf8Enabled = false)
: ExportToZipTask(outputPath, QDir(dir), files, destinationPrefix, followSymlinks, utf8Enabled){};
virtual ~ExportToZipTask() = default; virtual ~ExportToZipTask() = default;

View File

@ -201,7 +201,7 @@ void FlamePackExportTask::makeApiRequest()
<< " reason: " << parseError.errorString(); << " reason: " << parseError.errorString();
qWarning() << *response; qWarning() << *response;
failed(parseError.errorString()); emitFailed(parseError.errorString());
return; return;
} }
@ -213,6 +213,7 @@ void FlamePackExportTask::makeApiRequest()
if (dataArr.isEmpty()) { if (dataArr.isEmpty()) {
qWarning() << "No matches found for fingerprint search!"; qWarning() << "No matches found for fingerprint search!";
getProjectsInfo();
return; return;
} }
for (auto match : dataArr) { for (auto match : dataArr) {
@ -243,9 +244,9 @@ void FlamePackExportTask::makeApiRequest()
qDebug() << doc; qDebug() << doc;
} }
pendingHashes.clear(); pendingHashes.clear();
getProjectsInfo();
}); });
connect(task.get(), &Task::finished, this, &FlamePackExportTask::getProjectsInfo); connect(task.get(), &NetJob::failed, this, &FlamePackExportTask::getProjectsInfo);
connect(task.get(), &NetJob::failed, this, &FlamePackExportTask::emitFailed);
task->start(); task->start();
} }
@ -279,7 +280,7 @@ void FlamePackExportTask::getProjectsInfo()
qWarning() << "Error while parsing JSON response from CurseForge projects task at " << parseError.offset qWarning() << "Error while parsing JSON response from CurseForge projects task at " << parseError.offset
<< " reason: " << parseError.errorString(); << " reason: " << parseError.errorString();
qWarning() << *response; qWarning() << *response;
failed(parseError.errorString()); emitFailed(parseError.errorString());
return; return;
} }
@ -333,7 +334,7 @@ void FlamePackExportTask::buildZip()
setStatus(tr("Adding files...")); setStatus(tr("Adding files..."));
setProgress(4, 5); setProgress(4, 5);
auto zipTask = makeShared<MMCZip::ExportToZipTask>(output, gameRoot, files, "overrides/", true); auto zipTask = makeShared<MMCZip::ExportToZipTask>(output, gameRoot, files, "overrides/", true, false);
zipTask->addExtraFile("manifest.json", generateIndex()); zipTask->addExtraFile("manifest.json", generateIndex());
zipTask->addExtraFile("modlist.html", generateHTML()); zipTask->addExtraFile("modlist.html", generateHTML());

View File

@ -200,7 +200,7 @@ void ModrinthPackExportTask::buildZip()
{ {
setStatus(tr("Adding files...")); setStatus(tr("Adding files..."));
auto zipTask = makeShared<MMCZip::ExportToZipTask>(output, gameRoot, files, "overrides/", true); auto zipTask = makeShared<MMCZip::ExportToZipTask>(output, gameRoot, files, "overrides/", true, true);
zipTask->addExtraFile("modrinth.index.json", generateIndex()); zipTask->addExtraFile("modrinth.index.json", generateIndex());
zipTask->setExcludeFiles(resolvedFiles.keys()); zipTask->setExcludeFiles(resolvedFiles.keys());

View File

@ -146,7 +146,7 @@ void ExportInstanceDialog::doExport()
return; return;
} }
auto task = makeShared<MMCZip::ExportToZipTask>(output, m_instance->instanceRoot(), files, "", true); auto task = makeShared<MMCZip::ExportToZipTask>(output, m_instance->instanceRoot(), files, "", true, true);
connect(task.get(), &Task::failed, this, connect(task.get(), &Task::failed, this,
[this, output](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); }); [this, output](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });