RemoteLinux: Use more FilePath in AbstractPackagingStep

Change-Id: I66533efd39f58f9bcc4a57334d427aa225bc73d8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-10-27 12:00:41 +02:00
parent 14a81406e3
commit b153aa5459
5 changed files with 26 additions and 25 deletions

View File

@@ -32,9 +32,9 @@
#include <projectexplorer/task.h>
#include <QDateTime>
#include <QFileInfo>
using namespace ProjectExplorer;
using namespace Utils;
namespace RemoteLinux {
namespace Internal {
@@ -42,8 +42,8 @@ namespace Internal {
class AbstractPackagingStepPrivate
{
public:
QString cachedPackageFilePath;
QString cachedPackageDirectory;
FilePath cachedPackageFilePath;
FilePath cachedPackageDirectory;
bool deploymentDataModified = false;
};
@@ -67,37 +67,37 @@ AbstractPackagingStep::~AbstractPackagingStep()
delete d;
}
QString AbstractPackagingStep::cachedPackageFilePath() const
FilePath AbstractPackagingStep::cachedPackageFilePath() const
{
return d->cachedPackageFilePath;
}
QString AbstractPackagingStep::packageFilePath() const
FilePath AbstractPackagingStep::packageFilePath() const
{
if (packageDirectory().isEmpty())
return QString();
return packageDirectory() + QLatin1Char('/') + packageFileName();
return {};
return packageDirectory().pathAppended(packageFileName());
}
QString AbstractPackagingStep::cachedPackageDirectory() const
FilePath AbstractPackagingStep::cachedPackageDirectory() const
{
return d->cachedPackageDirectory;
}
QString AbstractPackagingStep::packageDirectory() const
FilePath AbstractPackagingStep::packageDirectory() const
{
return buildDirectory().toString();
return buildDirectory();
}
bool AbstractPackagingStep::isPackagingNeeded() const
{
QFileInfo packageInfo(packageFilePath());
if (!packageInfo.exists() || d->deploymentDataModified)
const FilePath packagePath = packageFilePath();
if (!packagePath.exists() || d->deploymentDataModified)
return true;
const DeploymentData &dd = target()->deploymentData();
for (int i = 0; i < dd.fileCount(); ++i) {
if (dd.fileAt(i).localFilePath().isNewerThan(packageInfo.lastModified()))
if (dd.fileAt(i).localFilePath().isNewerThan(packagePath.lastModified()))
return true;
}

View File

@@ -41,8 +41,8 @@ public:
explicit AbstractPackagingStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id);
~AbstractPackagingStep() override;
QString packageFilePath() const;
QString cachedPackageFilePath() const;
Utils::FilePath packageFilePath() const;
Utils::FilePath cachedPackageFilePath() const;
bool init() override;
signals:
@@ -54,8 +54,8 @@ protected:
void raiseError(const QString &errorMessage);
void raiseWarning(const QString &warningMessage);
QString cachedPackageDirectory() const;
QString packageDirectory() const;
Utils::FilePath cachedPackageDirectory() const;
Utils::FilePath packageDirectory() const;
virtual bool isPackagingNeeded() const;

View File

@@ -71,9 +71,9 @@ AbstractUploadAndInstallPackageService::~AbstractUploadAndInstallPackageService(
delete d;
}
void AbstractUploadAndInstallPackageService::setPackageFilePath(const QString &filePath)
void AbstractUploadAndInstallPackageService::setPackageFilePath(const FilePath &filePath)
{
d->packageFilePath = FilePath::fromString(filePath);
d->packageFilePath = filePath;
}
QString AbstractUploadAndInstallPackageService::uploadDir() const

View File

@@ -38,7 +38,7 @@ class REMOTELINUX_EXPORT AbstractUploadAndInstallPackageService : public Abstrac
Q_OBJECT
public:
void setPackageFilePath(const QString &filePath);
void setPackageFilePath(const Utils::FilePath &filePath);
protected:
AbstractUploadAndInstallPackageService();

View File

@@ -87,11 +87,11 @@ TarPackageCreationStep::TarPackageCreationStep(BuildStepList *bsl, Utils::Id id)
m_incrementalDeploymentAspect->setSettingsKey(IncrementalDeploymentKey);
setSummaryUpdater([this] {
QString path = packageFilePath();
FilePath path = packageFilePath();
if (path.isEmpty())
return QString("<font color=\"red\">" + tr("Tarball creation not possible.")
+ "</font>");
return QString("<b>" + tr("Create tarball:") + "</b> " + path);
return QString("<b>" + tr("Create tarball:") + "</b> " + path.toUserOutput());
});
}
@@ -148,11 +148,12 @@ bool TarPackageCreationStep::doPackage()
}
// TODO: Optimization: Only package changed files
QFile tarFile(cachedPackageFilePath());
const FilePath tarFilePath = cachedPackageFilePath();
QFile tarFile(tarFilePath.toString());
if (!tarFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
raiseError(tr("Error: tar file %1 cannot be opened (%2).")
.arg(QDir::toNativeSeparators(cachedPackageFilePath()), tarFile.errorString()));
.arg(tarFilePath.toUserOutput(), tarFile.errorString()));
return false;
}
@@ -311,7 +312,7 @@ bool TarPackageCreationStep::writeHeader(QFile &tarFile, const QFileInfo &fileIn
header.chksum[sizeof header.chksum-1] = 0;
if (!tarFile.write(reinterpret_cast<char *>(&header), sizeof header)) {
raiseError(tr("Error writing tar file \"%1\": %2")
.arg(QDir::toNativeSeparators(cachedPackageFilePath()), tarFile.errorString()));
.arg(cachedPackageFilePath().toUserOutput(), tarFile.errorString()));
return false;
}
return true;