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,
|
QDateTime GenericDirectUploadService::timestampFromStat(const DeployableFile &file,
|
||||||
QtcProcess *statProc,
|
QtcProcess *statProc)
|
||||||
const QString &errorMsg)
|
|
||||||
{
|
{
|
||||||
QString errorDetails;
|
bool succeeded = false;
|
||||||
if (!errorMsg.isEmpty())
|
QString error;
|
||||||
errorDetails = errorMsg;
|
if (statProc->error() == QProcess::FailedToStart) {
|
||||||
else if (statProc->exitCode() != 0)
|
error = tr("Failed to start \"stat\": %1").arg(statProc->errorString());
|
||||||
errorDetails = QString::fromUtf8(statProc->readAllStandardError());
|
} else if (statProc->exitStatus() == QProcess::CrashExit) {
|
||||||
if (!errorDetails.isEmpty()) {
|
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\". "
|
emit warningMessage(tr("Failed to retrieve remote timestamp for file \"%1\". "
|
||||||
"Incremental deployment will not work. Error message was: %2")
|
"Incremental deployment will not work. Error message was: %2")
|
||||||
.arg(file.remoteFilePath(), errorDetails));
|
.arg(file.remoteFilePath(), error));
|
||||||
return QDateTime();
|
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")
|
const QString warningString(tr("Unexpected stat output for remote file \"%1\": %2")
|
||||||
.arg(file.remoteFilePath()).arg(QString::fromUtf8(output)));
|
.arg(file.remoteFilePath()).arg(QString::fromUtf8(output)));
|
||||||
if (!output.startsWith(file.remoteFilePath().toUtf8())) {
|
if (!output.startsWith(file.remoteFilePath().toUtf8())) {
|
||||||
@@ -205,7 +211,7 @@ void GenericDirectUploadService::runStat(const DeployableFile &file)
|
|||||||
QTC_ASSERT(d->state == state, return);
|
QTC_ASSERT(d->state == state, return);
|
||||||
const DeployableFile file = d->getFileForProcess(statProc);
|
const DeployableFile file = d->getFileForProcess(statProc);
|
||||||
QTC_ASSERT(file.isValid(), return);
|
QTC_ASSERT(file.isValid(), return);
|
||||||
const QDateTime timestamp = timestampFromStat(file, statProc, statProc->errorString());
|
const QDateTime timestamp = timestampFromStat(file, statProc);
|
||||||
statProc->deleteLater();
|
statProc->deleteLater();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PreChecking:
|
case PreChecking:
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void runStat(const ProjectExplorer::DeployableFile &file);
|
void runStat(const ProjectExplorer::DeployableFile &file);
|
||||||
QDateTime timestampFromStat(const ProjectExplorer::DeployableFile &file,
|
QDateTime timestampFromStat(const ProjectExplorer::DeployableFile &file,
|
||||||
Utils::QtcProcess *statProc, const QString &errorMsg);
|
Utils::QtcProcess *statProc);
|
||||||
void checkForStateChangeOnRemoteProcFinished();
|
void checkForStateChangeOnRemoteProcFinished();
|
||||||
|
|
||||||
QList<ProjectExplorer::DeployableFile> collectFilesToUpload(
|
QList<ProjectExplorer::DeployableFile> collectFilesToUpload(
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ private:
|
|||||||
void sendControlSignal(Utils::ControlSignal controlSignal) override;
|
void sendControlSignal(Utils::ControlSignal controlSignal) override;
|
||||||
|
|
||||||
void handleStarted(qint64 processId) final;
|
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 handleReadyReadStandardOutput(const QByteArray &outputData) final;
|
||||||
void handleReadyReadStandardError(const QByteArray &errorData) final;
|
void handleReadyReadStandardError(const QByteArray &errorData) final;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user