summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2023-08-24 13:22:02 +0300
committerKatja Marttila <katja.marttila@qt.io>2023-08-24 13:29:47 +0300
commit5d52e6a2c5b32e0f96e44ef867b4fee12cfb2437 (patch)
tree3c856ff9abd50145e6474613991e7b9cbe1d4074
parenta9fd39352c3d3717fb9ea33871bb8e3a2ddf5483 (diff)
parente99494a7abfd8509decd2ab46f84bc9e5bd5794f (diff)
Merge remote-tracking branch 'origin/4.6' into master
-rw-r--r--.qmake.conf1
-rw-r--r--src/libs/installer/downloadarchivesjob.cpp35
-rw-r--r--src/libs/installer/downloadarchivesjob.h2
-rw-r--r--src/libs/installer/metadatajob.cpp5
-rw-r--r--src/libs/installer/packagemanagercore.cpp9
-rw-r--r--src/libs/installer/packagemanagergui.cpp3
-rw-r--r--tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp2
7 files changed, 39 insertions, 18 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 0bdc8dcee..57b97ccc9 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1 +1,2 @@
VERSION=4.7.0
+CONFIG=prepare_docs qt_docs_targets $$CONFIG
diff --git a/src/libs/installer/downloadarchivesjob.cpp b/src/libs/installer/downloadarchivesjob.cpp
index 48700bd12..fcad22cfa 100644
--- a/src/libs/installer/downloadarchivesjob.cpp
+++ b/src/libs/installer/downloadarchivesjob.cpp
@@ -44,6 +44,8 @@ using namespace QInstaller;
using namespace KDUpdater;
+static constexpr uint scMaxRetries = 5;
+
/*!
Creates a new DownloadArchivesJob with parent \a core.
*/
@@ -58,6 +60,7 @@ DownloadArchivesJob::DownloadArchivesJob(PackageManagerCore *core)
, m_progressChangedTimerId(0)
, m_totalSizeToDownload(0)
, m_totalSizeDownloaded(0)
+ , m_retryCount(scMaxRetries)
{
setCapabilities(Cancelable);
}
@@ -290,16 +293,21 @@ void DownloadArchivesJob::registerFile()
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
QLatin1String("DownloadError"), tr("Download Error"), tr("Hash verification while "
"downloading failed. This is a temporary error, please retry."),
- QMessageBox::Retry | QMessageBox::Cancel, QMessageBox::Cancel);
+ QMessageBox::Retry | QMessageBox::Cancel, QMessageBox::Retry);
- // If run from command line instance, do not continue if hash verification failed.
- // Same download is tried again and again causing infinite loop if hash not
- // fixed to repositories.
- if (res == QMessageBox::Cancel || m_core->isCommandLineInstance()) {
+ if (res == QMessageBox::Cancel) {
finishWithError(tr("Cannot verify Hash"));
return;
}
+ // When using command line instance, only retry a number of times to avoid
+ // infinite loop in case the automatic answer for the messagebox is "Retry"
+ if (m_core->isCommandLineInstance() && (--m_retryCount == 0)) {
+ finishWithError(tr("Retry count (%1) exceeded").arg(scMaxRetries));
+ return;
+ }
} else {
+ m_retryCount = scMaxRetries;
+
++m_archivesDownloaded;
m_totalSizeDownloaded += QFile(m_downloader->downloadedFileName()).size();
if (m_progressChangedTimerId) {
@@ -330,14 +338,21 @@ void DownloadArchivesJob::downloadFailed(const QString &error)
const QMessageBox::StandardButton b =
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
QLatin1String("archiveDownloadError"), tr("Download Error"), tr("Cannot download archive %1: %2")
- .arg(m_archivesToDownload.first().sourceUrl, error), QMessageBox::Retry | QMessageBox::Cancel);
+ .arg(m_archivesToDownload.first().sourceUrl, error), QMessageBox::Retry | QMessageBox::Cancel,
+ QMessageBox::Retry);
+
+ if (b == QMessageBox::Retry) {
+ // When using command line instance, only retry a number of times to avoid
+ // infinite loop in case the automatic answer for the messagebox is "Retry"
+ if (m_core->isCommandLineInstance() && (--m_retryCount == 0)) {
+ finishWithError(tr("Retry count (%1) exceeded").arg(scMaxRetries));
+ return;
+ }
- // Do not call fetchNextArchiveHash when using command line instance,
- // installer tries to download the same archive causing infinite loop
- if (b == QMessageBox::Retry && !m_core->isCommandLineInstance())
QMetaObject::invokeMethod(this, "fetchNextArchiveHash", Qt::QueuedConnection);
- else
+ } else {
downloadCanceled();
+ }
}
void DownloadArchivesJob::finishWithError(const QString &error)
diff --git a/src/libs/installer/downloadarchivesjob.h b/src/libs/installer/downloadarchivesjob.h
index c156d0244..122af2831 100644
--- a/src/libs/installer/downloadarchivesjob.h
+++ b/src/libs/installer/downloadarchivesjob.h
@@ -103,6 +103,8 @@ private:
quint64 m_totalSizeToDownload;
quint64 m_totalSizeDownloaded;
QElapsedTimer m_totalDownloadSpeedTimer;
+
+ uint m_retryCount;
};
} // namespace QInstaller
diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp
index 9c719c761..968ab2f34 100644
--- a/src/libs/installer/metadatajob.cpp
+++ b/src/libs/installer/metadatajob.cpp
@@ -235,12 +235,13 @@ void MetadataJob::doStart()
if (m_downloadType != DownloadType::CompressedPackage) {
emit infoMessage(this, tr("Fetching latest update information..."));
const bool onlineInstaller = m_core->isInstaller() && !m_core->isOfflineOnly();
- if (onlineInstaller || m_core->isMaintainer()) {
+ const QSet<Repository> repositories = getRepositories();
+
+ if (onlineInstaller || m_core->isMaintainer() || !repositories.isEmpty()) {
static const QString updateFilePath(QLatin1Char('/') + scUpdatesXML + QLatin1Char('?'));
static const QString randomQueryString = QString::number(QRandomGenerator::global()->generate());
QList<FileTaskItem> items;
- QSet<Repository> repositories = getRepositories();
quint64 cachedCount = 0;
foreach (const Repository &repo, repositories) {
// For not blocking the UI
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 0c4f13470..977323ec1 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -804,12 +804,13 @@ quint64 PackageManagerCore::requiredDiskSpace() const
*/
quint64 PackageManagerCore::requiredTemporaryDiskSpace() const
{
- if (isOfflineOnly())
- return 0;
-
quint64 result = 0;
- foreach (QInstaller::Component *component, orderedComponentsToInstall())
+ foreach (QInstaller::Component *component, orderedComponentsToInstall()) {
+ if (!component->isFromOnlineRepository())
+ continue;
+
result += size(component, scCompressedSize);
+ }
return result;
}
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp
index 5ee382771..3acf9278c 100644
--- a/src/libs/installer/packagemanagergui.cpp
+++ b/src/libs/installer/packagemanagergui.cpp
@@ -1452,9 +1452,10 @@ int PackageManagerPage::nextId() const
if (next == PackageManagerCore::LicenseCheck) {
// calculate the page after the license page
const int nextNextId = gui()->pageIds().value(gui()->pageIds().indexOf(next) + 1, -1);
- const PackageManagerCore *const core = packageManagerCore();
+ PackageManagerCore *const core = packageManagerCore();
if (core->isUninstaller())
return nextNextId; // forcibly hide the license page if we run as uninstaller
+ core->recalculateAllComponents();
foreach (Component* component, core->orderedComponentsToInstall()) {
if (core->isMaintainer() && component->isInstalled())
diff --git a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
index 24697243c..5db79cc55 100644
--- a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
+++ b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
@@ -195,7 +195,7 @@ private slots:
setRepository(":///data/missingarchive");
core->autoAcceptMessageBoxes();
core->installSelectedComponentsSilently(QStringList () << "C");
- QCOMPARE(PackageManagerCore::Canceled, core->status());
+ QCOMPARE(PackageManagerCore::Failure, core->status()); // Fails after retrying
}
void messageBoxFromScriptDefaultAnswer()