Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[vault] garbage collection action: gc
Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
  • Loading branch information
Denis Zalevskiy committed Oct 28, 2014
1 parent 7534966 commit 53930cf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -23,4 +23,5 @@ units/vault-*
*.moc
tests/tests.xml
tests/*_unit.cpp
tests/*_vault_test
tests/*_vault_test
src/config.hpp
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Expand Up @@ -9,6 +9,8 @@ link_directories(

set(CMAKE_AUTOMOC TRUE)

configure_file(config.hpp.in config.hpp @ONLY)

add_library(vault-core SHARED vault.cpp vault_config.cpp)
qt5_use_modules(vault-core Core)
target_link_libraries(vault-core
Expand Down
6 changes: 6 additions & 0 deletions src/config.hpp.in
@@ -0,0 +1,6 @@
#ifndef _SRC_VAULT_CONFIG_HPP_
#define _SRC_VAULT_CONFIG_HPP_

#define VAULT_LIBEXEC_PATH "@prefix@/libexec/vault"

#endif // _SRC_VAULT_CONFIG_HPP_
12 changes: 11 additions & 1 deletion src/vault.cpp
Expand Up @@ -6,6 +6,7 @@
* @par License: LGPL 2.1 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*/

#include "config.hpp"
#include <vault/vault.hpp>

#include <qtaround/util.hpp>
Expand All @@ -29,7 +30,6 @@ namespace subprocess = qtaround::subprocess;
namespace error = qtaround::error;
namespace debug = qtaround::debug;


namespace vault {

static const QMap<File, QString> fileNames = {
Expand Down Expand Up @@ -185,6 +185,16 @@ int Vault::execute(const QVariantMap &options)
error::raise({{"action", action}, {"msg", "Needs unit name"}});
}
vault.unregisterUnit(options.value("unit").toString());
} else if (action == "gc") {
auto p = subprocess::Process();
p.setWorkingDirectory(vault.root());
p.start(os::path::join(VAULT_LIBEXEC_PATH, "git-vault-gc"), {});
p.wait(-1);
QTextStream out(stdout, QIODevice::WriteOnly);
QTextStream err(stderr, QIODevice::WriteOnly);
out << p.stdout() << endl;
err << p.stderr() << endl;
return p.rc();
} else {
error::raise({{"msg", "Unknown action"}, {"action", action}});
}
Expand Down

0 comments on commit 53930cf

Please sign in to comment.