Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into clean_net

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2024-07-22 22:06:09 +03:00
46 changed files with 368 additions and 214 deletions

View File

@@ -60,7 +60,11 @@ class ChecksumValidator : public Validator {
return true;
}
auto abort() -> bool override { return true; }
auto abort() -> bool override
{
m_checksum.reset();
return true;
}
auto validate(QNetworkReply&) -> bool override
{

View File

@@ -36,6 +36,7 @@
*/
#include "NetJob.h"
#include <QNetworkReply>
#include "net/NetRequest.h"
#include "tasks/ConcurrentTask.h"
#if defined(LAUNCHER_APPLICATION)
@@ -145,10 +146,23 @@ void NetJob::updateState()
.arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(totalSize())));
}
bool NetJob::isOnline()
{
// check some errors that are ussually associated with the lack of internet
for (auto job : getFailedActions()) {
auto err = job->error();
if (err != QNetworkReply::HostNotFoundError && err != QNetworkReply::NetworkSessionFailedError) {
return true;
}
}
return false;
};
void NetJob::emitFailed(QString reason)
{
#if defined(LAUNCHER_APPLICATION)
if (m_ask_retry) {
if (m_ask_retry && m_manual_try < APPLICATION->settings()->get("NumberOfManualRetries").toInt() && isOnline()) {
m_manual_try++;
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
"The tasks failed.\n"
"Failed urls\n" +

View File

@@ -74,10 +74,12 @@ class NetJob : public ConcurrentTask {
protected:
void updateState() override;
bool isOnline();
private:
shared_qobject_ptr<QNetworkAccessManager> m_network;
int m_try = 1;
bool m_ask_retry = true;
int m_manual_try = 0;
};

View File

@@ -84,7 +84,7 @@ void NetRequest::executeTask()
break;
case State::Inactive:
case State::Failed:
emit failed("Failed to initilize sink");
emit failed("Failed to initialize sink");
emit finished();
return;
case State::AbortedByUser: