diff --git a/src/plugins/remotelinux/genericdirectuploadservice.cpp b/src/plugins/remotelinux/genericdirectuploadservice.cpp index c784e346b9a..f4aed62bfd6 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.cpp +++ b/src/plugins/remotelinux/genericdirectuploadservice.cpp @@ -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: diff --git a/src/plugins/remotelinux/genericdirectuploadservice.h b/src/plugins/remotelinux/genericdirectuploadservice.h index 42af64e3823..ffbd9fc866d 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.h +++ b/src/plugins/remotelinux/genericdirectuploadservice.h @@ -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 collectFilesToUpload( diff --git a/src/plugins/remotelinux/linuxprocessinterface.h b/src/plugins/remotelinux/linuxprocessinterface.h index c6ee39384b6..110e6939f8c 100644 --- a/src/plugins/remotelinux/linuxprocessinterface.h +++ b/src/plugins/remotelinux/linuxprocessinterface.h @@ -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;