forked from qt-creator/qt-creator
GenericDirectUploadService: Fix error handling of stat process
Don't rely on error detection based on error string contents. The translators may have provided empty strings (by mistake) and this may influence the behavior. Change-Id: I035ead2ddd93787b268798607d3f856981f0c862 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -136,21 +136,27 @@ void GenericDirectUploadService::doDeploy()
|
||||
}
|
||||
|
||||
QDateTime GenericDirectUploadService::timestampFromStat(const DeployableFile &file,
|
||||
QtcProcess *statProc,
|
||||
const QString &errorMsg)
|
||||
QtcProcess *statProc)
|
||||
{
|
||||
QString errorDetails;
|
||||
if (!errorMsg.isEmpty())
|
||||
errorDetails = errorMsg;
|
||||
else if (statProc->exitCode() != 0)
|
||||
errorDetails = QString::fromUtf8(statProc->readAllStandardError());
|
||||
if (!errorDetails.isEmpty()) {
|
||||
bool succeeded = false;
|
||||
QString error;
|
||||
if (statProc->error() == QProcess::FailedToStart) {
|
||||
error = tr("Failed to start \"stat\": %1").arg(statProc->errorString());
|
||||
} else if (statProc->exitStatus() == QProcess::CrashExit) {
|
||||
error = tr("\"stat\" crashed.");
|
||||
} else if (statProc->exitCode() != 0) {
|
||||
error = tr("\"stat\" failed with exit code %1: %2")
|
||||
.arg(statProc->exitCode()).arg(statProc->stdErr());
|
||||
} else {
|
||||
succeeded = true;
|
||||
}
|
||||
if (!succeeded) {
|
||||
emit warningMessage(tr("Failed to retrieve remote timestamp for file \"%1\". "
|
||||
"Incremental deployment will not work. Error message was: %2")
|
||||
.arg(file.remoteFilePath(), errorDetails));
|
||||
.arg(file.remoteFilePath(), error));
|
||||
return QDateTime();
|
||||
}
|
||||
QByteArray output = statProc->readAllStandardOutput().trimmed();
|
||||
const QByteArray output = statProc->readAllStandardOutput().trimmed();
|
||||
const QString warningString(tr("Unexpected stat output for remote file \"%1\": %2")
|
||||
.arg(file.remoteFilePath()).arg(QString::fromUtf8(output)));
|
||||
if (!output.startsWith(file.remoteFilePath().toUtf8())) {
|
||||
@@ -205,7 +211,7 @@ void GenericDirectUploadService::runStat(const DeployableFile &file)
|
||||
QTC_ASSERT(d->state == state, return);
|
||||
const DeployableFile file = d->getFileForProcess(statProc);
|
||||
QTC_ASSERT(file.isValid(), return);
|
||||
const QDateTime timestamp = timestampFromStat(file, statProc, statProc->errorString());
|
||||
const QDateTime timestamp = timestampFromStat(file, statProc);
|
||||
statProc->deleteLater();
|
||||
switch (state) {
|
||||
case PreChecking:
|
||||
|
||||
@@ -61,7 +61,7 @@ protected:
|
||||
private:
|
||||
void runStat(const ProjectExplorer::DeployableFile &file);
|
||||
QDateTime timestampFromStat(const ProjectExplorer::DeployableFile &file,
|
||||
Utils::QtcProcess *statProc, const QString &errorMsg);
|
||||
Utils::QtcProcess *statProc);
|
||||
void checkForStateChangeOnRemoteProcFinished();
|
||||
|
||||
QList<ProjectExplorer::DeployableFile> collectFilesToUpload(
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
void sendControlSignal(Utils::ControlSignal controlSignal) override;
|
||||
|
||||
void handleStarted(qint64 processId) final;
|
||||
void handleDone(const Utils::ProcessResultData &resultData);
|
||||
void handleDone(const Utils::ProcessResultData &resultData) final;
|
||||
void handleReadyReadStandardOutput(const QByteArray &outputData) final;
|
||||
void handleReadyReadStandardError(const QByteArray &errorData) final;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user