From f24fd246048dae2e494a2f4c16b5927b521328e2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 13 Apr 2017 18:23:42 +0100 Subject: Initialize git library once on startup --- gentoobrowse-api/service/main.cpp | 5 ++++- gentoobrowse-api/service/maintenanceGitOperations.cpp | 4 ---- gentoobrowse-api/service/utils/git.cpp | 10 ---------- gentoobrowse-api/service/utils/git.h | 6 ------ 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/gentoobrowse-api/service/main.cpp b/gentoobrowse-api/service/main.cpp index ce32be0..3221e4c 100644 --- a/gentoobrowse-api/service/main.cpp +++ b/gentoobrowse-api/service/main.cpp @@ -9,6 +9,7 @@ #include #include +#include namespace Gentoo { namespace Service { @@ -17,13 +18,15 @@ class Api : public IceTray::Service { Api() { xmlInitParser(); - // exsltRegisterAll(); + exsltRegisterAll(); + git_libgit2_init(); } ~Api() { xsltCleanupGlobals(); xmlCleanupParser(); + git_libgit2_shutdown(); } void addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr & adp) override diff --git a/gentoobrowse-api/service/maintenanceGitOperations.cpp b/gentoobrowse-api/service/maintenanceGitOperations.cpp index 8941dc2..0b909b9 100644 --- a/gentoobrowse-api/service/maintenanceGitOperations.cpp +++ b/gentoobrowse-api/service/maintenanceGitOperations.cpp @@ -95,8 +95,6 @@ namespace Gentoo { void Maintenance::updateRepositories(const Ice::Current &) { - libgit2 git; - auto dbc = db->get(); sql::maintenance::reposToUpdate.select(dbc.get())->forEachRow(&updateRepository); } @@ -165,8 +163,6 @@ namespace Gentoo { void Maintenance::refreshPackageTreeGit(const Ice::Current & c) { - libgit2 git; - auto properties = c.adapter->getCommunicator()->getProperties(); auto repoRoot = boost::filesystem::path(properties->getPropertyWithDefault("GentooBrowseAPI.RepoRoot", "/")); auto dbc = db->get(); diff --git a/gentoobrowse-api/service/utils/git.cpp b/gentoobrowse-api/service/utils/git.cpp index bbd69a3..ce1556a 100644 --- a/gentoobrowse-api/service/utils/git.cpp +++ b/gentoobrowse-api/service/utils/git.cpp @@ -16,16 +16,6 @@ namespace Gentoo { throw ::Gentoo::GitError(*fn, err, e->klass, e->message); } - libgit2::libgit2() - { - git_libgit2_init(); - } - - libgit2::~libgit2() - { - git_libgit2_shutdown(); - } - AdHocFormatter(RefSpec, "refs/heads/%?:refs/remotes/%?/%?"); std::unique_ptr gitFetch(git_repository * repo, git_remote * remote, const char * remoteBranchName) diff --git a/gentoobrowse-api/service/utils/git.h b/gentoobrowse-api/service/utils/git.h index 6900435..ec3afad 100644 --- a/gentoobrowse-api/service/utils/git.h +++ b/gentoobrowse-api/service/utils/git.h @@ -33,12 +33,6 @@ namespace Gentoo { return r; } - class libgit2 { - public: - libgit2(); - ~libgit2(); - }; - std::unique_ptr gitFetch(git_repository * repo, git_remote * remote, const char * branch); -- cgit v1.2.3