diff --git a/lib/unit.cpp b/lib/unit.cpp index 0ba1d22..ca26bbd 100644 --- a/lib/unit.cpp +++ b/lib/unit.cpp @@ -14,6 +14,9 @@ #include #include +#include +#include +#include namespace os = qtaround::os; namespace error = qtaround::error; @@ -22,6 +25,8 @@ namespace util = qtaround::util; namespace json = qtaround::json; namespace debug = qtaround::debug; +Q_LOGGING_CATEGORY(lcBackup, "org.sailfishos.backup", QtWarningMsg) + namespace vault { namespace unit { static const unsigned current_version = 1; @@ -496,4 +501,30 @@ int execute(std::unique_ptr, QVariantMap const &info) return 0; } +int execute(QVariantMap const &info) +{ + try { + Operation op(getopt(), info); + op.execute(); + } catch (error::Error const &e) { + qCDebug(lcBackup) << e; + return 1; + } + return 0; +} + +int runProcess(const QString &program, const QStringList &args) +{ + QProcess ps; + ps.start(program, args); + ps.waitForFinished(-1); + if (ps.exitStatus() == QProcess::CrashExit || ps.exitCode() != 0) { + qCDebug(lcBackup) << ps.program() << "failed"; + qCDebug(lcBackup) << ps.readAllStandardError(); + qCDebug(lcBackup) << ps.readAllStandardOutput(); + return 1; + } + return 0; +} + }} // namespace vault::unit diff --git a/lib/unit.h b/lib/unit.h index 0fc8ed5..361b545 100644 --- a/lib/unit.h +++ b/lib/unit.h @@ -9,7 +9,7 @@ */ #include - +#include #include namespace qtaround { namespace sys { class GetOpt; }} @@ -21,6 +21,10 @@ options_uptr getopt(); int execute(options_uptr, QVariantMap const &info); +int execute(QVariantMap const &info); + +int runProcess(const QString &program, const QStringList &args); + }} #endif // _CUTES_UNIT_HPP_ diff --git a/rpm/vault.spec b/rpm/vault.spec index 0abf919..0a40283 100644 --- a/rpm/vault.spec +++ b/rpm/vault.spec @@ -1,8 +1,8 @@ Summary: Incremental backup/restore framework Name: vault -Version: 1.0.0 +Version: 1.0.1 Release: 1 -License: LGPLv2.1 +License: LGPLv2 Group: Development/Libraries URL: https://git.sailfishos.org/mer-core/vault Source0: %{name}-%{version}.tar.bz2