Merge pull request #2440 from Trial97/fix_retry_dialog
update retry netjob dialog
This commit is contained in:
commit
0041d2a126
@ -559,6 +559,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||||||
|
|
||||||
m_settings->registerSetting("NumberOfConcurrentTasks", 10);
|
m_settings->registerSetting("NumberOfConcurrentTasks", 10);
|
||||||
m_settings->registerSetting("NumberOfConcurrentDownloads", 6);
|
m_settings->registerSetting("NumberOfConcurrentDownloads", 6);
|
||||||
|
m_settings->registerSetting("NumberOfManualRetries", 1);
|
||||||
m_settings->registerSetting("RequestTimeout", 60);
|
m_settings->registerSetting("RequestTimeout", 60);
|
||||||
|
|
||||||
QString defaultMonospace;
|
QString defaultMonospace;
|
||||||
|
@ -74,6 +74,7 @@ void Flame::FileResolvingTask::netJobFinished()
|
|||||||
setProgress(1, 3);
|
setProgress(1, 3);
|
||||||
// job to check modrinth for blocked projects
|
// job to check modrinth for blocked projects
|
||||||
m_checkJob.reset(new NetJob("Modrinth check", m_network));
|
m_checkJob.reset(new NetJob("Modrinth check", m_network));
|
||||||
|
m_checkJob->setAskRetry(false);
|
||||||
blockedProjects = QMap<File*, std::shared_ptr<QByteArray>>();
|
blockedProjects = QMap<File*, std::shared_ptr<QByteArray>>();
|
||||||
|
|
||||||
QJsonDocument doc;
|
QJsonDocument doc;
|
||||||
|
@ -58,7 +58,6 @@ auto ApiDownload::makeFile(QUrl url, QString path, Options options) -> Download:
|
|||||||
|
|
||||||
void ApiDownload::init()
|
void ApiDownload::init()
|
||||||
{
|
{
|
||||||
qDebug() << "Setting up api download";
|
|
||||||
auto api_headers = new ApiHeaderProxy();
|
auto api_headers = new ApiHeaderProxy();
|
||||||
addHeaderProxy(api_headers);
|
addHeaderProxy(api_headers);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ Upload::Ptr ApiUpload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> outpu
|
|||||||
|
|
||||||
void ApiUpload::init()
|
void ApiUpload::init()
|
||||||
{
|
{
|
||||||
qDebug() << "Setting up api upload";
|
|
||||||
auto api_headers = new ApiHeaderProxy();
|
auto api_headers = new ApiHeaderProxy();
|
||||||
addHeaderProxy(api_headers);
|
addHeaderProxy(api_headers);
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NetJob.h"
|
#include "NetJob.h"
|
||||||
|
#include <QNetworkReply>
|
||||||
#include "net/NetRequest.h"
|
#include "net/NetRequest.h"
|
||||||
#include "tasks/ConcurrentTask.h"
|
#include "tasks/ConcurrentTask.h"
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#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())));
|
.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)
|
void NetJob::emitFailed(QString reason)
|
||||||
{
|
{
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#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",
|
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
|
||||||
"The tasks failed.\n"
|
"The tasks failed.\n"
|
||||||
"Failed urls\n" +
|
"Failed urls\n" +
|
||||||
|
@ -74,10 +74,12 @@ class NetJob : public ConcurrentTask {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateState() override;
|
void updateState() override;
|
||||||
|
bool isOnline();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
|
|
||||||
int m_try = 1;
|
int m_try = 1;
|
||||||
bool m_ask_retry = true;
|
bool m_ask_retry = true;
|
||||||
|
int m_manual_try = 0;
|
||||||
};
|
};
|
||||||
|
@ -58,6 +58,7 @@ void NewsChecker::reloadNews()
|
|||||||
|
|
||||||
NetJob::Ptr job{ new NetJob("News RSS Feed", m_network) };
|
NetJob::Ptr job{ new NetJob("News RSS Feed", m_network) };
|
||||||
job->addNetAction(Net::Download::makeByteArray(m_feedUrl, newsData));
|
job->addNetAction(Net::Download::makeByteArray(m_feedUrl, newsData));
|
||||||
|
job->setAskRetry(false);
|
||||||
QObject::connect(job.get(), &NetJob::succeeded, this, &NewsChecker::rssDownloadFinished);
|
QObject::connect(job.get(), &NetJob::succeeded, this, &NewsChecker::rssDownloadFinished);
|
||||||
QObject::connect(job.get(), &NetJob::failed, this, &NewsChecker::rssDownloadFailed);
|
QObject::connect(job.get(), &NetJob::failed, this, &NewsChecker::rssDownloadFailed);
|
||||||
m_newsNetJob.reset(job);
|
m_newsNetJob.reset(job);
|
||||||
|
@ -553,6 +553,7 @@ void TranslationsModel::downloadIndex()
|
|||||||
auto task = Net::Download::makeCached(QUrl(BuildConfig.TRANSLATIONS_BASE_URL + "index_v2.json"), entry);
|
auto task = Net::Download::makeCached(QUrl(BuildConfig.TRANSLATIONS_BASE_URL + "index_v2.json"), entry);
|
||||||
d->m_index_task = task.get();
|
d->m_index_task = task.get();
|
||||||
d->m_index_job->addNetAction(task);
|
d->m_index_job->addNetAction(task);
|
||||||
|
d->m_index_job->setAskRetry(false);
|
||||||
connect(d->m_index_job.get(), &NetJob::failed, this, &TranslationsModel::indexFailed);
|
connect(d->m_index_job.get(), &NetJob::failed, this, &TranslationsModel::indexFailed);
|
||||||
connect(d->m_index_job.get(), &NetJob::succeeded, this, &TranslationsModel::indexReceived);
|
connect(d->m_index_job.get(), &NetJob::succeeded, this, &TranslationsModel::indexReceived);
|
||||||
d->m_index_job->start();
|
d->m_index_job->start();
|
||||||
|
@ -203,6 +203,7 @@ void LauncherPage::applySettings()
|
|||||||
|
|
||||||
s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value());
|
s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value());
|
||||||
s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value());
|
s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value());
|
||||||
|
s->set("NumberOfManualRetries", ui->numberOfManualRetriesSpinBox->value());
|
||||||
s->set("RequestTimeout", ui->timeoutSecondsSpinBox->value());
|
s->set("RequestTimeout", ui->timeoutSecondsSpinBox->value());
|
||||||
|
|
||||||
// Console settings
|
// Console settings
|
||||||
@ -261,6 +262,7 @@ void LauncherPage::loadSettings()
|
|||||||
|
|
||||||
ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
|
ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
|
||||||
ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt());
|
ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt());
|
||||||
|
ui->numberOfManualRetriesSpinBox->setValue(s->get("NumberOfManualRetries").toInt());
|
||||||
ui->timeoutSecondsSpinBox->setValue(s->get("RequestTimeout").toInt());
|
ui->timeoutSecondsSpinBox->setValue(s->get("RequestTimeout").toInt());
|
||||||
|
|
||||||
// Console settings
|
// Console settings
|
||||||
|
@ -307,6 +307,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="numberOfManualRetriesLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Number of manual retries</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QSpinBox" name="numberOfManualRetriesSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -317,8 +317,10 @@ std::optional<QIcon> ResourceModel::getIcon(QModelIndex& index, const QUrl& url)
|
|||||||
if (QPixmapCache::find(url.toString(), &pixmap))
|
if (QPixmapCache::find(url.toString(), &pixmap))
|
||||||
return { pixmap };
|
return { pixmap };
|
||||||
|
|
||||||
if (!m_current_icon_job)
|
if (!m_current_icon_job) {
|
||||||
m_current_icon_job.reset(new NetJob("IconJob", APPLICATION->network()));
|
m_current_icon_job.reset(new NetJob("IconJob", APPLICATION->network()));
|
||||||
|
m_current_icon_job->setAskRetry(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_currently_running_icon_actions.contains(url))
|
if (m_currently_running_icon_actions.contains(url))
|
||||||
return {};
|
return {};
|
||||||
|
@ -195,6 +195,7 @@ void ListModel::requestLogo(QString file, QString url)
|
|||||||
|
|
||||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(file));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", QString("logos/%1").arg(file));
|
||||||
auto job = new NetJob(QString("ATLauncher Icon Download %1").arg(file), APPLICATION->network());
|
auto job = new NetJob(QString("ATLauncher Icon Download %1").arg(file), APPLICATION->network());
|
||||||
|
job->setAskRetry(false);
|
||||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
||||||
|
|
||||||
auto fullPath = entry->getFullPath();
|
auto fullPath = entry->getFullPath();
|
||||||
|
@ -110,6 +110,7 @@ void ListModel::requestLogo(QString logo, QString url)
|
|||||||
|
|
||||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FlamePacks", QString("logos/%1").arg(logo));
|
||||||
auto job = new NetJob(QString("Flame Icon Download %1").arg(logo), APPLICATION->network());
|
auto job = new NetJob(QString("Flame Icon Download %1").arg(logo), APPLICATION->network());
|
||||||
|
job->setAskRetry(false);
|
||||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
||||||
|
|
||||||
auto fullPath = entry->getFullPath();
|
auto fullPath = entry->getFullPath();
|
||||||
|
@ -264,6 +264,7 @@ void ListModel::requestLogo(QString file)
|
|||||||
|
|
||||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file));
|
||||||
NetJob* job = new NetJob(QString("FTB Icon Download for %1").arg(file), APPLICATION->network());
|
NetJob* job = new NetJob(QString("FTB Icon Download for %1").arg(file), APPLICATION->network());
|
||||||
|
job->setAskRetry(false);
|
||||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry));
|
job->addNetAction(Net::ApiDownload::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry));
|
||||||
|
|
||||||
auto fullPath = entry->getFullPath();
|
auto fullPath = entry->getFullPath();
|
||||||
|
@ -254,6 +254,7 @@ void ModpackListModel::requestLogo(QString logo, QString url)
|
|||||||
|
|
||||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry(m_parent->metaEntryBase(), QString("logos/%1").arg(logo));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry(m_parent->metaEntryBase(), QString("logos/%1").arg(logo));
|
||||||
auto job = new NetJob(QString("%1 Icon Download %2").arg(m_parent->debugName()).arg(logo), APPLICATION->network());
|
auto job = new NetJob(QString("%1 Icon Download %2").arg(m_parent->debugName()).arg(logo), APPLICATION->network());
|
||||||
|
job->setAskRetry(false);
|
||||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
||||||
|
|
||||||
auto fullPath = entry->getFullPath();
|
auto fullPath = entry->getFullPath();
|
||||||
|
@ -292,6 +292,7 @@ void Technic::ListModel::requestLogo(QString logo, QString url)
|
|||||||
|
|
||||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("TechnicPacks", QString("logos/%1").arg(logo));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("TechnicPacks", QString("logos/%1").arg(logo));
|
||||||
auto job = new NetJob(QString("Technic Icon Download %1").arg(logo), APPLICATION->network());
|
auto job = new NetJob(QString("Technic Icon Download %1").arg(logo), APPLICATION->network());
|
||||||
|
job->setAskRetry(false);
|
||||||
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
job->addNetAction(Net::ApiDownload::makeCached(QUrl(url), entry));
|
||||||
|
|
||||||
auto fullPath = entry->getFullPath();
|
auto fullPath = entry->getFullPath();
|
||||||
|
@ -80,7 +80,7 @@ void VariableSizedImageObject::drawObject(QPainter* painter,
|
|||||||
{
|
{
|
||||||
if (!format.hasProperty(ImageData)) {
|
if (!format.hasProperty(ImageData)) {
|
||||||
QUrl image_url{ qvariant_cast<QString>(format.property(QTextFormat::ImageName)) };
|
QUrl image_url{ qvariant_cast<QString>(format.property(QTextFormat::ImageName)) };
|
||||||
if (m_fetching_images.contains(image_url))
|
if (m_fetching_images.contains(image_url) || image_url.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto meta = std::make_shared<ImageMetadata>();
|
auto meta = std::make_shared<ImageMetadata>();
|
||||||
@ -140,6 +140,7 @@ void VariableSizedImageObject::loadImage(QTextDocument* doc, std::shared_ptr<Ima
|
|||||||
QString("images/%1").arg(QString(QCryptographicHash::hash(meta->url.toEncoded(), QCryptographicHash::Algorithm::Sha1).toHex())));
|
QString("images/%1").arg(QString(QCryptographicHash::hash(meta->url.toEncoded(), QCryptographicHash::Algorithm::Sha1).toHex())));
|
||||||
|
|
||||||
auto job = new NetJob(QString("Load Image: %1").arg(meta->url.fileName()), APPLICATION->network());
|
auto job = new NetJob(QString("Load Image: %1").arg(meta->url.fileName()), APPLICATION->network());
|
||||||
|
job->setAskRetry(false);
|
||||||
job->addNetAction(Net::ApiDownload::makeCached(meta->url, entry));
|
job->addNetAction(Net::ApiDownload::makeCached(meta->url, entry));
|
||||||
|
|
||||||
auto full_entry_path = entry->getFullPath();
|
auto full_entry_path = entry->getFullPath();
|
||||||
|
Loading…
Reference in New Issue
Block a user