summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-03-16 10:21:26 +0200
committerKatja Marttila <katja.marttila@qt.io>2020-03-16 10:35:50 +0200
commitcf47ae2dcceeacb63d37dcffffa3ff37b1c50342 (patch)
treebe7382f930eff628261a70ee3774a5245ea5ea5b /src/libs
parent02a7a7b8c4e4cc8d5cb2ec64074d32a7598c373a (diff)
parentc0732c406741bbd3d8d16f32f599e7ce83155c85 (diff)
Merge remote-tracking branch 'origin/3.2' to master
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/component.cpp6
-rw-r--r--src/libs/installer/constants.h1
-rw-r--r--src/libs/installer/environmentvariablesoperation.cpp2
-rw-r--r--src/libs/installer/extractarchiveoperation.cpp1
-rw-r--r--src/libs/installer/packagemanagercore.cpp103
-rw-r--r--src/libs/installer/packagemanagercore.h3
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp2
-rw-r--r--src/libs/installer/packagemanagercore_p.h1
-rw-r--r--src/libs/installer/packagemanagergui.cpp95
9 files changed, 121 insertions, 93 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index 7ad68d24d..503b9434c 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -50,7 +50,11 @@
#include <QtUiTools/QUiLoader>
+#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
+#include <private/qv4engine_p.h>
+#else
#include <private/qv8engine_p.h>
+#endif
#include <private/qv4scopedvalue_p.h>
#include <private/qv4object_p.h>
@@ -552,7 +556,7 @@ void Component::loadComponentScript(const QString &fileName)
}
} catch (const Error &error) {
if (packageManagerCore()->settings().allowUnstableComponents()) {
- setUnstable(Component::Component::ScriptLoadingFailed, error.message());
+ setUnstable(Component::UnstableError::ScriptLoadingFailed, error.message());
qCWarning(QInstaller::lcInstallerInstallLog) << error.message();
} else {
throw error;
diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h
index 7fd2a0eef..ad97227dc 100644
--- a/src/libs/installer/constants.h
+++ b/src/libs/installer/constants.h
@@ -113,6 +113,7 @@ const char Updater[] = "updater";
const char ManagePackages[] = "manage-packages";
const char Uninstaller[] = "uninstaller";
const char NoForceInstallation[] = "no-force-installations";
+const char NoSizeChecking[] = "no-size-checking";
const char ShowVirtualComponents[] = "show-virtual-components";
const char LoggingRules[] = "logging-rules";
const char CreateLocalRepository[] = "create-local-repository";
diff --git a/src/libs/installer/environmentvariablesoperation.cpp b/src/libs/installer/environmentvariablesoperation.cpp
index 953379ba7..95ea54800 100644
--- a/src/libs/installer/environmentvariablesoperation.cpp
+++ b/src/libs/installer/environmentvariablesoperation.cpp
@@ -239,7 +239,7 @@ bool EnvironmentVariableOperation::undoOperation()
const bool doUndo = actual == value;
if (doUndo)
Environment::instance().setTemporaryValue(name, oldvalue);
- return doUndo;
+ return true;
}
#ifdef Q_OS_WIN
diff --git a/src/libs/installer/extractarchiveoperation.cpp b/src/libs/installer/extractarchiveoperation.cpp
index d755a5320..9ae35cb77 100644
--- a/src/libs/installer/extractarchiveoperation.cpp
+++ b/src/libs/installer/extractarchiveoperation.cpp
@@ -34,6 +34,7 @@
#include <QEventLoop>
#include <QThreadPool>
#include <QFileInfo>
+#include <QDataStream>
namespace QInstaller {
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index a1ba7e1f2..8a0ee2585 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -2288,6 +2288,109 @@ void PackageManagerCore::dropAdminRights()
}
/*!
+ Sets checkAvailableSpace based on value of \c check.
+*/
+void PackageManagerCore::setCheckAvailableSpace(bool check)
+{
+ d->m_checkAvailableSpace = check;
+}
+
+/*!
+ Checks available disk space if the feature is not explicitly disabled. Informative
+ text about space status can be retrieved by passing \c message parameter. Returns
+ \a true if there is sufficient free space on installation and temporary volumes.
+*/
+bool PackageManagerCore::checkAvailableSpace(QString &message) const
+{
+ const quint64 extraSpace = 256 * 1024 * 1024LL;
+ quint64 required(requiredDiskSpace());
+ quint64 tempRequired(requiredTemporaryDiskSpace());
+ if (required < extraSpace) {
+ required += 0.1 * required;
+ tempRequired += 0.1 * tempRequired;
+ } else {
+ required += extraSpace;
+ tempRequired += extraSpace;
+ }
+
+ quint64 repositorySize = 0;
+ const bool createLocalRepository = createLocalRepositoryFromBinary();
+ if (createLocalRepository && isInstaller()) {
+ repositorySize = QFile(QCoreApplication::applicationFilePath()).size();
+ // if we create a local repository, take that space into account as well
+ required += repositorySize;
+ }
+
+ qDebug() << "Installation space required:" << humanReadableSize(required) << "Temporary space "
+ "required:" << humanReadableSize(tempRequired) << "Local repository size:"
+ << humanReadableSize(repositorySize);
+
+ if (d->m_checkAvailableSpace) {
+ const VolumeInfo tempVolume = VolumeInfo::fromPath(QDir::tempPath());
+ const VolumeInfo targetVolume = VolumeInfo::fromPath(value(scTargetDir));
+
+ const quint64 tempVolumeAvailableSize = tempVolume.availableSize();
+ const quint64 installVolumeAvailableSize = targetVolume.availableSize();
+
+ // at the moment there is no better way to check this
+ if (targetVolume.size() == 0 && installVolumeAvailableSize == 0) {
+ qDebug().nospace() << "Cannot determine available space on device. "
+ "Volume descriptor: " << targetVolume.volumeDescriptor()
+ << ", Mount path: " << targetVolume.mountPath() << ". Continue silently.";
+ return true;
+ }
+
+ const bool tempOnSameVolume = (targetVolume == tempVolume);
+ if (tempOnSameVolume) {
+ qDebug() << "Tmp and install directories are on the same volume. Volume mount point:"
+ << targetVolume.mountPath() << "Free space available:"
+ << humanReadableSize(installVolumeAvailableSize);
+ } else {
+ qDebug() << "Tmp is on a different volume than the installation directory. Tmp volume mount point:"
+ << tempVolume.mountPath() << "Free space available:"
+ << humanReadableSize(tempVolumeAvailableSize) << "Install volume mount point:"
+ << targetVolume.mountPath() << "Free space available:"
+ << humanReadableSize(installVolumeAvailableSize);
+ }
+
+ if (tempOnSameVolume && (installVolumeAvailableSize <= (required + tempRequired))) {
+ message = tr("Not enough disk space to store temporary files and the "
+ "installation. %1 are available, while %2 are at least required.").arg(
+ humanReadableSize(installVolumeAvailableSize), humanReadableSize(required + tempRequired));
+ return false;
+ }
+
+ if (installVolumeAvailableSize < required) {
+ message = tr("Not enough disk space to store all selected components! %1 are "
+ "available while %2 are at least required.").arg(humanReadableSize(installVolumeAvailableSize),
+ humanReadableSize(required));
+ return false;
+ }
+
+ if (tempVolumeAvailableSize < tempRequired) {
+ message = tr("Not enough disk space to store temporary files! %1 are available "
+ "while %2 are at least required.").arg(humanReadableSize(tempVolumeAvailableSize),
+ humanReadableSize(tempRequired));
+ return false;
+ }
+
+ if (installVolumeAvailableSize - required < 0.01 * targetVolume.size()) {
+ // warn for less than 1% of the volume's space being free
+ message = tr("The volume you selected for installation seems to have sufficient space for "
+ "installation, but there will be less than 1% of the volume's space available afterwards.");
+ } else if (installVolumeAvailableSize - required < 100 * 1024 * 1024LL) {
+ // warn for less than 100MB being free
+ message = tr("The volume you selected for installation seems to have sufficient "
+ "space for installation, but there will be less than 100 MB available afterwards.");
+ }
+ }
+ message = QString::fromLatin1("%1 %2").arg(message, tr("Installation will use %1 of disk space.")
+ .arg(humanReadableSize(requiredDiskSpace()))).simplified();
+
+ return true;
+}
+
+/*!
Returns \c true if a process with \a name is running. On Windows, the comparison
is case-insensitive.
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index 1ca0e05ef..76a0a7341 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -249,6 +249,9 @@ public:
Q_INVOKABLE bool gainAdminRights();
Q_INVOKABLE void dropAdminRights();
+ void setCheckAvailableSpace(bool check);
+ bool checkAvailableSpace(QString &message) const;
+
Q_INVOKABLE quint64 requiredDiskSpace() const;
Q_INVOKABLE quint64 requiredTemporaryDiskSpace() const;
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index b7c03c21a..190d297f0 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -218,6 +218,7 @@ PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core)
, m_foundEssentialUpdate(false)
, m_commandLineInstance(false)
, m_userSetBinaryMarker(false)
+ , m_checkAvailableSpace(true)
{
}
@@ -251,6 +252,7 @@ PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core, q
, m_foundEssentialUpdate(false)
, m_commandLineInstance(false)
, m_userSetBinaryMarker(false)
+ , m_checkAvailableSpace(true)
{
foreach (const OperationBlob &operation, performedOperations) {
QScopedPointer<QInstaller::Operation> op(KDUpdater::UpdateOperationFactory::instance()
diff --git a/src/libs/installer/packagemanagercore_p.h b/src/libs/installer/packagemanagercore_p.h
index 961822994..e246317cc 100644
--- a/src/libs/installer/packagemanagercore_p.h
+++ b/src/libs/installer/packagemanagercore_p.h
@@ -188,6 +188,7 @@ public:
bool m_launchedAsRoot;
bool m_commandLineInstance;
bool m_userSetBinaryMarker;
+ bool m_checkAvailableSpace;
bool m_completeUninstall;
bool m_needToWriteMaintenanceTool;
PackageManagerCoreData m_data;
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp
index 05f61ae18..793519416 100644
--- a/src/libs/installer/packagemanagergui.cpp
+++ b/src/libs/installer/packagemanagergui.cpp
@@ -2411,102 +2411,15 @@ void ReadyForInstallationPage::entering()
m_taskDetailsBrowser->setVisible(!componentsOk || isVerbose());
setComplete(componentsOk);
- const VolumeInfo tempVolume = VolumeInfo::fromPath(QDir::tempPath());
- const VolumeInfo targetVolume = VolumeInfo::fromPath(packageManagerCore()->value(scTargetDir));
-
- const quint64 tempVolumeAvailableSize = tempVolume.availableSize();
- const quint64 installVolumeAvailableSize = targetVolume.availableSize();
-
- // at the moment there is no better way to check this
- if (targetVolume.size() == 0 && installVolumeAvailableSize == 0) {
- qCWarning(QInstaller::lcInstallerInstallLog).nospace() << "Cannot determine available space on device. "
- "Volume descriptor: " << targetVolume.volumeDescriptor()
- << ", Mount path: " << targetVolume.mountPath() << ". Continue silently.";
- return; // TODO: Shouldn't this also disable the "Next" button?
- }
-
- const bool tempOnSameVolume = (targetVolume == tempVolume);
- if (tempOnSameVolume) {
- qCDebug(QInstaller::lcInstallerInstallLog) << "Tmp and install directories are on the same volume. "
- "Volume mount point:" << targetVolume.mountPath() << "Free space available:"
- << humanReadableSize(installVolumeAvailableSize);
- } else {
- qCDebug(QInstaller::lcInstallerInstallLog) << "Tmp is on a different volume than the installation "
- "directory. Tmp volume mount point:"
- << tempVolume.mountPath() << "Free space available:"
- << humanReadableSize(tempVolumeAvailableSize) << "Install volume mount point:"
- << targetVolume.mountPath() << "Free space available:"
- << humanReadableSize(installVolumeAvailableSize);
- }
-
- const quint64 extraSpace = 256 * 1024 * 1024LL;
- quint64 required(packageManagerCore()->requiredDiskSpace());
- quint64 tempRequired(packageManagerCore()->requiredTemporaryDiskSpace());
- if (required < extraSpace) {
- required += 0.1 * required;
- tempRequired += 0.1 * tempRequired;
+ QString spaceInfo;
+ if (packageManagerCore()->checkAvailableSpace(spaceInfo)) {
+ m_msgLabel->setText(QString::fromLatin1("%1 %2").arg(m_msgLabel->text(), spaceInfo));
} else {
- required += extraSpace;
- tempRequired += extraSpace;
- }
-
- quint64 repositorySize = 0;
- const bool createLocalRepository = packageManagerCore()->createLocalRepositoryFromBinary();
- if (createLocalRepository && packageManagerCore()->isInstaller()) {
- repositorySize = QFile(QCoreApplication::applicationFilePath()).size();
- // if we create a local repository, take that space into account as well
- required += repositorySize;
- }
-
- qCDebug(QInstaller::lcInstallerInstallLog) << "Installation space required:"
- << humanReadableSize(required) << "Temporary space "
- "required:" << humanReadableSize(tempRequired) << "Local repository size:"
- << humanReadableSize(repositorySize);
-
- if (tempOnSameVolume && (installVolumeAvailableSize <= (required + tempRequired))) {
- m_msgLabel->setText(tr("Not enough disk space to store temporary files and the "
- "installation. %1 are available, while %2 are at least required.")
- .arg(humanReadableSize(installVolumeAvailableSize),
- humanReadableSize(required + tempRequired)));
- setComplete(false);
- return;
- }
-
- if (installVolumeAvailableSize < required) {
- m_msgLabel->setText(tr("Not enough disk space to store all selected components! %1 are available "
- "while %2 are at least required.").arg(humanReadableSize(installVolumeAvailableSize),
- humanReadableSize(required)));
- setComplete(false);
- return;
- }
-
- if (tempVolumeAvailableSize < tempRequired) {
- m_msgLabel->setText(tr("Not enough disk space to store temporary files! %1 are available "
- "while %2 are at least required.").arg(humanReadableSize(tempVolumeAvailableSize),
- humanReadableSize(tempRequired)));
+ m_msgLabel->setText(spaceInfo);
setComplete(false);
- return;
- }
-
- if (installVolumeAvailableSize - required < 0.01 * targetVolume.size()) {
- // warn for less than 1% of the volume's space being free
- m_msgLabel->setText(tr("The volume you selected for installation seems to have sufficient "
- "space for installation, but there will be less than 1% of the volume's space "
- "available afterwards. %1").arg(m_msgLabel->text()));
- } else if (installVolumeAvailableSize - required < 100 * 1024 * 1024LL) {
- // warn for less than 100MB being free
- m_msgLabel->setText(tr("The volume you selected for installation seems to have sufficient "
- "space for installation, but there will be less than 100 MB available afterwards. %1")
- .arg(m_msgLabel->text()));
}
-
- m_msgLabel->setText(QString::fromLatin1("%1 %2").arg(m_msgLabel->text(),
- tr("Installation will use %1 of disk space.")
- .arg(humanReadableSize(packageManagerCore()->requiredDiskSpace()))));
}
-
-
/*!
Called when end users leave the page and the PackageManagerGui:currentPageChanged()
signal is triggered.