From 7ed6657e30a742e2aad8a6e49cbd8aa3d8bbcc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 31 Mar 2018 23:49:37 +0100 Subject: [PATCH] Restore functionality of FileSystem::findExternal This also fixes unused variable warnings --- src/backend/corebackend.cpp | 1 + src/fs/filesystem.cpp | 13 ++++++++----- src/ops/backupoperation.h | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/backend/corebackend.cpp b/src/backend/corebackend.cpp index 380ffe1..5360610 100644 --- a/src/backend/corebackend.cpp +++ b/src/backend/corebackend.cpp @@ -69,6 +69,7 @@ QString CoreBackend::version() { void CoreBackend::setId(const QString& id) { d->m_id = id; } + void CoreBackend::setVersion(const QString& version) { d->m_version = version; } diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index b0e9f04..f540145 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -531,14 +531,17 @@ bool FileSystem::unmount(Report& report, const QString& deviceNode) return false; } -// FIXME: args and expectedCode is now unused. bool FileSystem::findExternal(const QString& cmdName, const QStringList& args, int expectedCode) { - QString cmd = QStandardPaths::findExecutable(cmdName); - if (cmd.isEmpty()) - cmd = QStandardPaths::findExecutable(cmdName, { QStringLiteral("/sbin/"), QStringLiteral("/usr/sbin/"), QStringLiteral("/usr/local/sbin/") }); + QString cmdFullPath = QStandardPaths::findExecutable(cmdName); + if (cmdFullPath.isEmpty()) + cmdFullPath = QStandardPaths::findExecutable(cmdName, { QStringLiteral("/sbin/"), QStringLiteral("/usr/sbin/"), QStringLiteral("/usr/local/sbin/") }); - return !cmd.isEmpty(); + ExternalCommand cmd(cmdFullPath, args); + if (!cmd.run()) + return false; + + return cmd.exitCode() == 0 || cmd.exitCode() == expectedCode; } bool FileSystem::supportToolFound() const diff --git a/src/ops/backupoperation.h b/src/ops/backupoperation.h index 9f3002d..21fd3f8 100644 --- a/src/ops/backupoperation.h +++ b/src/ops/backupoperation.h @@ -61,6 +61,7 @@ protected: Device& targetDevice() { return m_TargetDevice; } + const Device& targetDevice() const { return m_TargetDevice; }