Merge branch 'develop' of github.com:Trial97/PrismLauncher into feature/java-downloader
This commit is contained in:
commit
8ff53e47e8
2
.github/workflows/update-flake.yml
vendored
2
.github/workflows/update-flake.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26
|
||||
- uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b # v27
|
||||
|
||||
- uses: DeterminateSystems/update-flake-lock@v21
|
||||
with:
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "tasks/ConcurrentTask.h"
|
||||
#if defined(LAUNCHER_APPLICATION)
|
||||
#include "Application.h"
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
#endif
|
||||
|
||||
NetJob::NetJob(QString job_name, shared_qobject_ptr<QNetworkAccessManager> network) : ConcurrentTask(nullptr, job_name), m_network(network)
|
||||
@ -63,8 +64,11 @@ void NetJob::executeNextSubTask()
|
||||
// We're finished, check for failures and retry if we can (up to 3 times)
|
||||
if (isRunning() && m_queue.isEmpty() && m_doing.isEmpty() && !m_failed.isEmpty() && m_try < 3) {
|
||||
m_try += 1;
|
||||
while (!m_failed.isEmpty())
|
||||
m_queue.enqueue(m_failed.take(*m_failed.keyBegin()));
|
||||
while (!m_failed.isEmpty()) {
|
||||
auto task = m_failed.take(*m_failed.keyBegin());
|
||||
m_done.remove(task.get());
|
||||
m_queue.enqueue(task);
|
||||
}
|
||||
}
|
||||
ConcurrentTask::executeNextSubTask();
|
||||
}
|
||||
@ -136,3 +140,25 @@ void NetJob::updateState()
|
||||
setStatus(tr("Executing %1 task(s) (%2 out of %3 are done)")
|
||||
.arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(totalSize())));
|
||||
}
|
||||
|
||||
void NetJob::emitFailed(QString reason)
|
||||
{
|
||||
#if defined(LAUNCHER_APPLICATION)
|
||||
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
|
||||
"The tasks failed\n"
|
||||
"Failed urls\n" +
|
||||
getFailedFiles().join("\n\t") +
|
||||
"\n"
|
||||
"If this continues to happen please check the logs of the application"
|
||||
"Do you want to retry?",
|
||||
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||
->exec();
|
||||
|
||||
if (response == QMessageBox::Yes) {
|
||||
m_try = 0;
|
||||
executeNextSubTask();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
ConcurrentTask::emitFailed(reason);
|
||||
}
|
@ -66,6 +66,7 @@ class NetJob : public ConcurrentTask {
|
||||
public slots:
|
||||
// Qt can't handle auto at the start for some reason?
|
||||
bool abort() override;
|
||||
void emitFailed(QString reason) override;
|
||||
|
||||
protected slots:
|
||||
void executeNextSubTask() override;
|
||||
|
Loading…
Reference in New Issue
Block a user