diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-03 14:07:06 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-03 14:07:06 +0000 |
commit | 4f08e4424736e2f4b94c1c17e5fe3b5542e50695 (patch) | |
tree | 5df59c7598d6e2e495eda333bdbf67da6c4f143a | |
parent | Basic notification service implementation (diff) | |
download | gentoobrowse-api-4f08e4424736e2f4b94c1c17e5fe3b5542e50695.tar.bz2 gentoobrowse-api-4f08e4424736e2f4b94c1c17e5fe3b5542e50695.tar.xz gentoobrowse-api-4f08e4424736e2f4b94c1c17e5fe3b5542e50695.zip |
Update filetypes from code const on refresh
-rw-r--r-- | gentoobrowse-api/service/maintenancePackageTree.cpp | 35 | ||||
-rw-r--r-- | gentoobrowse-api/service/maintenanceimpl.h | 1 |
2 files changed, 28 insertions, 8 deletions
diff --git a/gentoobrowse-api/service/maintenancePackageTree.cpp b/gentoobrowse-api/service/maintenancePackageTree.cpp index 022730b..5ba85ff 100644 --- a/gentoobrowse-api/service/maintenancePackageTree.cpp +++ b/gentoobrowse-api/service/maintenancePackageTree.cpp @@ -4,6 +4,7 @@ #include <sqlWriter.h> #include <buffer.h> #include <scopeExit.h> +#include "utils/dbUtils.h" #include <boost/filesystem/operations.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/algorithm/string/predicate.hpp> @@ -20,22 +21,24 @@ #include "maintenance/masksProcessor.h" #include "maintenance/newsProcessor.h" -/* -10 category metadata.xml {"(2,metadata.xml)"} +namespace Gentoo { + const std::string fileTypes( +R"DATA( 10 category metadata {"(2,metadata.xml)"} 4 package metadata.xml {"(3,metadata.xml)"} -1 ebuild metadata {"(1,metadata)","(2,md5-cache)"} +1 package metadata {"(1,metadata)","(2,md5-cache)"} +2 changelog {"(3,ChangeLog)"} +7 licenses {"(1,licenses)"} +8 manifests {"(3,Manifest)"} 5 use_global {"(1,profiles)","(2,use.desc)"} 6 use_local {"(1,profiles)","(2,use.local.desc)"} 9 use_grouped {"(1,profiles)","(2,desc)","(3,%.desc)"} 3 masks {"(1,profiles)","(2,package.mask)"} 11 news {"(1,metadata)","(2,news)","(4,%.txt)"} +)DATA"); -8 package manifests {"(3,Manifest)"} -2 changelog {"(3,ChangeLog)"} -7 licenses {"(1,licenses)"} -*/ +// 8 package manifests {"(3,Manifest)"} +// 7 licenses {"(1,licenses)"} -namespace Gentoo { namespace Service { Maintenance::FileProcessor::~FileProcessor() { @@ -153,6 +156,21 @@ namespace Gentoo { return repos; } + void Maintenance::updateFileTypes(DB::Connection * dbc) const + { + DB::TablePatch p; + p.dest = "gentoobrowse.filetypes"; + p.src = Utils::Database::emptyClone(dbc, p.dest); + p.pk = { "filetypeId" }; + p.cols = { "filetypeId", "description", "spec" }; + std::stringstream buf(fileTypes); + dbc->beginBulkUpload(p.src.c_str(), ""); + dbc->bulkUploadData(buf); + dbc->endBulkUpload(nullptr); + dbc->patchTable(&p); + Utils::Database::drop(dbc, p.src); + } + void Maintenance::processChanges(DB::Connection * dbc, const boost::filesystem::path & tmp, const RepoMap & repos) { @@ -201,6 +219,7 @@ namespace Gentoo { auto dbc = db->get(); dbc->execute("SET search_path = gentoobrowse, pg_catalog"); DB::TransactionScope tx(dbc.get()); + updateFileTypes(dbc.get()); auto repos = createTempFileList(dbc.get(), tmp); processChanges(dbc.get(), tmp, repos); dbc->execute("SET search_path = public, pg_catalog"); diff --git a/gentoobrowse-api/service/maintenanceimpl.h b/gentoobrowse-api/service/maintenanceimpl.h index 8104649..c150043 100644 --- a/gentoobrowse-api/service/maintenanceimpl.h +++ b/gentoobrowse-api/service/maintenanceimpl.h @@ -40,6 +40,7 @@ namespace Gentoo { void refreshChangeLogs(const Ice::Current &) override; private: + void updateFileTypes(DB::Connection *) const; static RepoMap createTempFileList(DB::Connection *, const boost::filesystem::path &); void processChanges(DB::Connection *, const boost::filesystem::path &, const RepoMap & repos); void fileDeleted(DB::Connection * dbc, const FileProcessors *, const boost::filesystem::path &, const RepoMap *, DB::SelectCommandPtr s); |