RemoteLinux: Remove CheckForFreeDiskSpaceStep

This step was of very little use out of the box, as it required the user
to pass sensible values for e.g. the required disk space. Making it
smart enough would require non-trivial effort for very little gain, in
particular as the concept hardly makes any sense at all in conjunction
with deployment via rsync.

Fixes: QTCREATORBUG-27081
Change-Id: I586fceb59947334eba19b10fcc94ecedc661908f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Christian Kandeler
2022-06-15 15:50:44 +02:00
parent 2dc343970b
commit ebfbc55166
11 changed files with 5 additions and 212 deletions

View File

@@ -52,7 +52,6 @@ QdbDeployConfigurationFactory::QdbDeployConfigurationFactory()
return prj->deploymentKnowledge() == DeploymentKnowledge::Bad
&& prj->hasMakeInstallEquivalent();
});
addInitialStep(RemoteLinux::Constants::CheckForFreeDiskSpaceId);
addInitialStep(Qdb::Constants::QdbStopApplicationStepId);
addInitialStep(RemoteLinux::Constants::DirectUploadStepId);
}

View File

@@ -45,7 +45,6 @@
#include <qtsupport/qtversionfactory.h>
#include <remotelinux/checkforfreediskspacestep.h>
#include <remotelinux/genericdirectuploadstep.h>
#include <remotelinux/makeinstallstep.h>
#include <remotelinux/remotelinux_constants.h>
@@ -177,8 +176,6 @@ public:
QdbStopApplicationStepFactory m_stopApplicationStepFactory;
QdbMakeDefaultAppStepFactory m_makeDefaultAppStepFactory;
QdbDeployStepFactory<RemoteLinux::CheckForFreeDiskSpaceStep>
m_checkForFreeDiskSpaceStepFactory{RemoteLinux::Constants::CheckForFreeDiskSpaceId};
QdbDeployStepFactory<RemoteLinux::GenericDirectUploadStep>
m_directUploadStepFactory{RemoteLinux::Constants::DirectUploadStepId};
QdbDeployStepFactory<RemoteLinux::MakeInstallStep>

View File

@@ -131,6 +131,11 @@ bool BuildStepList::fromMap(const QVariantMap &map)
}
bool handled = false;
Utils::Id stepId = idFromMap(bsData);
// pre-8.0 compat
if (stepId == "RemoteLinux.CheckForFreeDiskSpaceStep")
continue;
for (BuildStepFactory *factory : factories) {
if (factory->stepId() == stepId) {
if (factory->canHandle(this)) {

View File

@@ -54,7 +54,6 @@
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <remotelinux/checkforfreediskspacestep.h>
#include <remotelinux/genericdirectuploadstep.h>
#include <remotelinux/makeinstallstep.h>
#include <remotelinux/remotelinux_constants.h>
@@ -105,7 +104,6 @@ public:
&& prj->hasMakeInstallEquivalent();
});
addInitialStep(DeviceCheckBuildStep::stepId());
addInitialStep(RemoteLinux::Constants::CheckForFreeDiskSpaceId);
addInitialStep(QnxUploadStep::stepId());
}
};
@@ -123,7 +121,6 @@ public:
QnxDeviceFactory deviceFactory;
QnxDeployConfigurationFactory deployConfigFactory;
GenericQnxDeployStepFactory<QnxUploadStep> directUploadDeployFactory;
GenericQnxDeployStepFactory<RemoteLinux::CheckForFreeDiskSpaceStep> checkForFreeDiskSpaceDeployFactory;
GenericQnxDeployStepFactory<RemoteLinux::MakeInstallStep> makeInstallDeployFactory;
GenericQnxDeployStepFactory<DeviceCheckBuildStep> checkBuildDeployFactory;
QnxRunConfigurationFactory runConfigFactory;

View File

@@ -4,7 +4,6 @@ add_qtc_plugin(RemoteLinux
SOURCES
abstractremotelinuxdeployservice.cpp abstractremotelinuxdeployservice.h
abstractremotelinuxdeploystep.cpp abstractremotelinuxdeploystep.h
checkforfreediskspacestep.cpp checkforfreediskspacestep.h
customcommanddeploystep.cpp customcommanddeploystep.h
deploymenttimeinfo.cpp deploymenttimeinfo.h
genericdirectuploadservice.cpp genericdirectuploadservice.h

View File

@@ -1,153 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "checkforfreediskspacestep.h"
#include "abstractremotelinuxdeployservice.h"
#include <projectexplorer/devicesupport/idevice.h>
#include <utils/aspects.h>
#include <utils/fileutils.h>
#include <QScopeGuard>
#include <limits>
using namespace ProjectExplorer;
using namespace Utils;
namespace RemoteLinux {
class CheckForFreeDiskSpaceService : public AbstractRemoteLinuxDeployService
{
Q_DECLARE_TR_FUNCTIONS(RemoteLinux::CheckForFreeDiskSpaceService)
public:
CheckForFreeDiskSpaceService() {}
void setPathToCheck(const QString &path);
void setRequiredSpaceInBytes(quint64 sizeInBytes);
private:
bool isDeploymentNecessary() const override { return true; }
CheckResult isDeploymentPossible() const override;
void doDeploy() final;
void stopDeployment() final {}
QString m_pathToCheck;
quint64 m_requiredSpaceInBytes = 0;
};
void CheckForFreeDiskSpaceService::setPathToCheck(const QString &path)
{
m_pathToCheck = path;
}
void CheckForFreeDiskSpaceService::setRequiredSpaceInBytes(quint64 sizeInBytes)
{
m_requiredSpaceInBytes = sizeInBytes;
}
void CheckForFreeDiskSpaceService::doDeploy()
{
auto cleanup = qScopeGuard([this] { setFinished(); });
const FilePath path = deviceConfiguration()->filePath(m_pathToCheck);
const qint64 freeSpace = path.bytesAvailable();
if (freeSpace < 0) {
emit errorMessage(tr("Cannot get info about free disk space for \"%1\"")
.arg(path.displayName()));
handleDeploymentDone();
return;
}
const qint64 mb = 1024 * 1024;
const qint64 freeSpaceMB = freeSpace / mb;
const qint64 requiredSpaceMB = m_requiredSpaceInBytes / mb;
if (freeSpaceMB < requiredSpaceMB) {
emit errorMessage(tr("The remote file system has only %n megabytes of free space, "
"but %1 megabytes are required.", nullptr, freeSpaceMB)
.arg(requiredSpaceMB));
handleDeploymentDone();
return;
}
emit progressMessage(tr("The remote file system has %n megabytes of free space, going ahead.",
nullptr, freeSpaceMB));
handleDeploymentDone();
}
CheckResult CheckForFreeDiskSpaceService::isDeploymentPossible() const
{
if (!m_pathToCheck.startsWith('/')) {
return CheckResult::failure(
tr("Cannot check for free disk space: \"%1\" is not an absolute path.")
.arg(m_pathToCheck));
}
return AbstractRemoteLinuxDeployService::isDeploymentPossible();
}
CheckForFreeDiskSpaceStep::CheckForFreeDiskSpaceStep
(BuildStepList *bsl, Id id)
: AbstractRemoteLinuxDeployStep(bsl, id)
{
auto service = createDeployService<CheckForFreeDiskSpaceService>();
auto pathToCheckAspect = addAspect<StringAspect>();
pathToCheckAspect->setSettingsKey("RemoteLinux.CheckForFreeDiskSpaceStep.PathToCheck");
pathToCheckAspect->setDisplayStyle(StringAspect::LineEditDisplay);
pathToCheckAspect->setValue("/");
pathToCheckAspect->setLabelText(tr("Remote path to check for free space:"));
auto requiredSpaceAspect = addAspect<IntegerAspect>();
requiredSpaceAspect->setSettingsKey("RemoteLinux.CheckForFreeDiskSpaceStep.RequiredSpace");
requiredSpaceAspect->setLabel(tr("Required disk space:"));
requiredSpaceAspect->setDisplayScaleFactor(1024*1024);
requiredSpaceAspect->setValue(5*1024*1024);
requiredSpaceAspect->setSuffix(tr("MB"));
requiredSpaceAspect->setRange(1, std::numeric_limits<int>::max());
setInternalInitializer([service, pathToCheckAspect, requiredSpaceAspect] {
service->setPathToCheck(pathToCheckAspect->value());
service->setRequiredSpaceInBytes(requiredSpaceAspect->value());
return CheckResult::success();
});
}
Id CheckForFreeDiskSpaceStep::stepId()
{
return "RemoteLinux.CheckForFreeDiskSpaceStep";
}
QString CheckForFreeDiskSpaceStep::displayName()
{
return tr("Check for free disk space");
}
} // namespace RemoteLinux

View File

@@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "remotelinux_export.h"
#include "abstractremotelinuxdeploystep.h"
namespace RemoteLinux {
class REMOTELINUX_EXPORT CheckForFreeDiskSpaceStep : public AbstractRemoteLinuxDeployStep
{
Q_OBJECT
public:
CheckForFreeDiskSpaceStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id);
static Utils::Id stepId();
static QString displayName();
};
} // namespace RemoteLinux

View File

@@ -19,8 +19,6 @@ Project {
"abstractremotelinuxdeploystep.h",
"deploymenttimeinfo.cpp",
"deploymenttimeinfo.h",
"checkforfreediskspacestep.cpp",
"checkforfreediskspacestep.h",
"customcommanddeploystep.cpp",
"customcommanddeploystep.h",
"genericdirectuploadservice.cpp",

View File

@@ -32,7 +32,6 @@ const char GenericLinuxOsType[] = "GenericLinuxOsType";
const char DeployToGenericLinux[] = "DeployToGenericLinux";
const char CheckForFreeDiskSpaceId[] = "RemoteLinux.CheckForFreeDiskSpaceStep";
const char DirectUploadStepId[] = "RemoteLinux.DirectUploadStep";
const char MakeInstallStepId[] = "RemoteLinux.MakeInstall";
const char TarPackageCreationStepId[] = "MaemoTarPackageCreationStep";

View File

@@ -63,7 +63,6 @@ RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory()
});
addInitialStep(Constants::MakeInstallStepId, needsMakeInstall);
addInitialStep(Constants::CheckForFreeDiskSpaceId);
addInitialStep(Constants::KillAppStepId);
addInitialStep(Constants::RsyncDeployStepId, [](Target *target) {
auto device = DeviceKitAspect::device(target->kit());

View File

@@ -25,7 +25,6 @@
#include "remotelinuxplugin.h"
#include "checkforfreediskspacestep.h"
#include "customcommanddeploystep.h"
#include "genericdirectuploadstep.h"
#include "killappstep.h"
@@ -79,7 +78,6 @@ public:
GenericDeployStepFactory<GenericDirectUploadStep> genericDirectUploadStepFactory;
GenericDeployStepFactory<RsyncDeployStep> rsyncDeployStepFactory;
CustomCommandDeployStepFactory customCommandDeployStepFactory;
GenericDeployStepFactory<CheckForFreeDiskSpaceStep> checkForFreeDiskSpaceStepFactory;
GenericDeployStepFactory<KillAppStep> killAppStepFactory;
GenericDeployStepFactory<MakeInstallStep> makeInstallStepFactory;