From 6078a771c18fd749f38d7c1a2f80ed3c7ec7ad28 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sat, 18 May 2024 21:46:05 +0300 Subject: [PATCH 1/3] add config for transfer timeout Signed-off-by: Trial97 --- launcher/Application.cpp | 10 ++++----- launcher/net/NetRequest.cpp | 4 ++++ launcher/ui/pages/global/LauncherPage.cpp | 2 ++ launcher/ui/pages/global/LauncherPage.ui | 27 ++++++++++++++++++----- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 96a50f2ba..ffa49ee11 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -559,6 +559,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) m_settings->registerSetting("NumberOfConcurrentTasks", 10); m_settings->registerSetting("NumberOfConcurrentDownloads", 6); + m_settings->registerSetting("DownlodTransferTimeout", 60); QString defaultMonospace; int defaultSize = 11; @@ -949,8 +950,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) [[fallthrough]]; default: { qDebug() << "Exiting because update lockfile is present"; - QMetaObject::invokeMethod( - this, []() { exit(1); }, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection); return; } } @@ -982,8 +982,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) [[fallthrough]]; default: { qDebug() << "Exiting because update lockfile is present"; - QMetaObject::invokeMethod( - this, []() { exit(1); }, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection); return; } } @@ -1671,8 +1670,7 @@ QString Application::getJarPath(QString jarFile) #if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) FS::PathCombine(m_rootPath, "share", BuildConfig.LAUNCHER_NAME), #endif - FS::PathCombine(m_rootPath, "jars"), - FS::PathCombine(applicationDirPath(), "jars"), + FS::PathCombine(m_rootPath, "jars"), FS::PathCombine(applicationDirPath(), "jars"), FS::PathCombine(applicationDirPath(), "..", "jars") // from inside build dir, for debuging }; for (QString p : potentialPaths) { diff --git a/launcher/net/NetRequest.cpp b/launcher/net/NetRequest.cpp index abecc0cf3..6ce6a9bfc 100644 --- a/launcher/net/NetRequest.cpp +++ b/launcher/net/NetRequest.cpp @@ -106,7 +106,11 @@ void NetRequest::executeTask() } #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +#if defined(LAUNCHER_APPLICATION) + request.setTransferTimeout(APPLICATION->settings()->get("DownlodTransferTimeout").toInt() * 1000); +#else request.setTransferTimeout(); +#endif #endif m_last_progress_time = m_clock.now(); diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 78c44380a..4b550a0fd 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -191,6 +191,7 @@ void LauncherPage::applySettings() s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value()); s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value()); + s->set("DownlodTransferTimeout", ui->timeoutSecondsSpinBox->value()); // Console settings s->set("ShowConsole", ui->showConsoleCheck->isChecked()); @@ -245,6 +246,7 @@ void LauncherPage::loadSettings() ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt()); ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt()); + ui->timeoutSecondsSpinBox->setValue(s->get("DownlodTransferTimeout").toInt()); // Console settings ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 928ec8103..20c9d0269 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -7,7 +7,7 @@ 0 0 511 - 629 + 691 @@ -205,6 +205,13 @@ Miscellaneous + + + + 1 + + + @@ -226,10 +233,20 @@ - - - - 1 + + + + Seconds to wait until the requests are terminated + + + Transfer timeout + + + + + + + s From d9e2badf71dc5b70e2cdaeac0ddde3a45891f953 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 19 May 2024 08:54:19 +0300 Subject: [PATCH 2/3] Rename timeout option Signed-off-by: Trial97 --- launcher/Application.cpp | 2 +- launcher/net/NetRequest.cpp | 2 +- launcher/ui/pages/global/LauncherPage.cpp | 4 ++-- launcher/ui/pages/global/LauncherPage.ui | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index ffa49ee11..da25f3e3f 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -559,7 +559,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) m_settings->registerSetting("NumberOfConcurrentTasks", 10); m_settings->registerSetting("NumberOfConcurrentDownloads", 6); - m_settings->registerSetting("DownlodTransferTimeout", 60); + m_settings->registerSetting("RequestTimeout", 60); QString defaultMonospace; int defaultSize = 11; diff --git a/launcher/net/NetRequest.cpp b/launcher/net/NetRequest.cpp index 6ce6a9bfc..dc9bf3b68 100644 --- a/launcher/net/NetRequest.cpp +++ b/launcher/net/NetRequest.cpp @@ -107,7 +107,7 @@ void NetRequest::executeTask() #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) #if defined(LAUNCHER_APPLICATION) - request.setTransferTimeout(APPLICATION->settings()->get("DownlodTransferTimeout").toInt() * 1000); + request.setTransferTimeout(APPLICATION->settings()->get("RequestTimeout").toInt() * 1000); #else request.setTransferTimeout(); #endif diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 4b550a0fd..085c78420 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -191,7 +191,7 @@ void LauncherPage::applySettings() s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value()); s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value()); - s->set("DownlodTransferTimeout", ui->timeoutSecondsSpinBox->value()); + s->set("RequestTimeout", ui->timeoutSecondsSpinBox->value()); // Console settings s->set("ShowConsole", ui->showConsoleCheck->isChecked()); @@ -246,7 +246,7 @@ void LauncherPage::loadSettings() ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt()); ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt()); - ui->timeoutSecondsSpinBox->setValue(s->get("DownlodTransferTimeout").toInt()); + ui->timeoutSecondsSpinBox->setValue(s->get("RequestTimeout").toInt()); // Console settings ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool()); diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 20c9d0269..62335b467 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -239,7 +239,7 @@ Seconds to wait until the requests are terminated - Transfer timeout + Timeout for HTTP requests From 425a6e09191eda8f732a6e1a6ca2b663d6e6d939 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 19 May 2024 10:09:34 +0300 Subject: [PATCH 3/3] Fix code format Signed-off-by: Trial97 --- launcher/Application.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index da25f3e3f..1781729a1 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -950,7 +950,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) [[fallthrough]]; default: { qDebug() << "Exiting because update lockfile is present"; - QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection); + QMetaObject::invokeMethod( + this, []() { exit(1); }, Qt::QueuedConnection); return; } } @@ -982,7 +983,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) [[fallthrough]]; default: { qDebug() << "Exiting because update lockfile is present"; - QMetaObject::invokeMethod(this, []() { exit(1); }, Qt::QueuedConnection); + QMetaObject::invokeMethod( + this, []() { exit(1); }, Qt::QueuedConnection); return; } } @@ -1670,7 +1672,8 @@ QString Application::getJarPath(QString jarFile) #if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) FS::PathCombine(m_rootPath, "share", BuildConfig.LAUNCHER_NAME), #endif - FS::PathCombine(m_rootPath, "jars"), FS::PathCombine(applicationDirPath(), "jars"), + FS::PathCombine(m_rootPath, "jars"), + FS::PathCombine(applicationDirPath(), "jars"), FS::PathCombine(applicationDirPath(), "..", "jars") // from inside build dir, for debuging }; for (QString p : potentialPaths) {