summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/packagemanagergui.cpp
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-02-25 16:03:54 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-02-27 09:03:58 +0000
commit0cb97d954d14b8703169a2b7208eea660c9691a8 (patch)
treede8b79ea4e6ccd86044856a3cdc665a51ba7255a /src/libs/installer/packagemanagergui.cpp
parentccafccfb442b2f1b3d0b70f5d899716cb787ee5a (diff)
Add command line option to disable checking of free space on target3.2.2-rc
Also move functionality to PackageManagerCore::checkAvailableSpace() for more convenient later usage, if we want to use this without starting the Wizard GUI. Task-number: QTIFW-1602 Change-Id: I4f2d3cc78bc542475fe9c51b9364b1b221098e4a Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer/packagemanagergui.cpp')
-rw-r--r--src/libs/installer/packagemanagergui.cpp93
1 files changed, 4 insertions, 89 deletions
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp
index 0ccd53da2..88e788b02 100644
--- a/src/libs/installer/packagemanagergui.cpp
+++ b/src/libs/installer/packagemanagergui.cpp
@@ -2538,100 +2538,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) {
- qDebug().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) {
- 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);
- }
-
- 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;
- }
-
- qDebug() << "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.