From kde-commits Sat Mar 31 22:50:12 2018 From: =?utf-8?q?Andrius_=C5=A0tikonas?= Date: Sat, 31 Mar 2018 22:50:12 +0000 To: kde-commits Subject: [kpmcore/kauth] src: Restore functionality of FileSystem::findExternal Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=152253662206187 Git commit 7ed6657e30a742e2aad8a6e49cbd8aa3d8bbcc42 by Andrius =C5=A0tikona= s. Committed on 31/03/2018 at 22:49. Pushed by stikonas into branch 'kauth'. Restore functionality of FileSystem::findExternal This also fixes unused variable warnings M +1 -0 src/backend/corebackend.cpp M +8 -5 src/fs/filesystem.cpp M +1 -0 src/ops/backupoperation.h https://commits.kde.org/kpmcore/7ed6657e30a742e2aad8a6e49cbd8aa3d8bbcc42 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 =3D id; } + void CoreBackend::setVersion(const QString& version) { d->m_version =3D 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 QStrin= g& deviceNode) return false; } = -// FIXME: args and expectedCode is now unused. bool FileSystem::findExternal(const QString& cmdName, const QStringList& a= rgs, int expectedCode) { - QString cmd =3D QStandardPaths::findExecutable(cmdName); - if (cmd.isEmpty()) - cmd =3D QStandardPaths::findExecutable(cmdName, { QStringLiteral("= /sbin/"), QStringLiteral("/usr/sbin/"), QStringLiteral("/usr/local/sbin/") = }); + QString cmdFullPath =3D QStandardPaths::findExecutable(cmdName); + if (cmdFullPath.isEmpty()) + cmdFullPath =3D QStandardPaths::findExecutable(cmdName, { QStringL= iteral("/sbin/"), QStringLiteral("/usr/sbin/"), QStringLiteral("/usr/local/= sbin/") }); = - return !cmd.isEmpty(); + ExternalCommand cmd(cmdFullPath, args); + if (!cmd.run()) + return false; + + return cmd.exitCode() =3D=3D 0 || cmd.exitCode() =3D=3D 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; }