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

View File

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

View File

@@ -71,9 +71,9 @@ AbstractUploadAndInstallPackageService::~AbstractUploadAndInstallPackageService(
delete d; 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 QString AbstractUploadAndInstallPackageService::uploadDir() const

View File

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

View File

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