From 01953224fc0f85b84b322bb266823c5f04686d32 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 1 Jun 2016 15:26:50 +0100 Subject: Don't delete packages and categories immediately when deleting ebuilds (they might come back), do them in apply --- .../service/maintenance/ebuildMetaProcessor.cpp | 20 ++++++++++++++------ .../service/maintenance/ebuildMetaProcessor.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp index 2ba14e7..ccb498a 100644 --- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp @@ -132,6 +132,19 @@ namespace Gentoo { t.dest = "gentoobrowse.ebuild_rdeps"; dbc->patchTable(&t); } + if (!catsDeleteFrom.empty()) { + bool any = false; + for(const auto & categoryName : catsDeleteFrom) { + // Prune packages + auto pp = dbc->modify(sql::maintenance::packagePrune.getSql()); + pp->bindParamS(0, categoryName); + any |= pp->execute(); + } + if (any) { + // Prune categories + dbc->modify(sql::maintenance::categoryPrune.getSql())->execute(); + } + } } void @@ -224,12 +237,7 @@ namespace Gentoo { m->bindParamS(2, packageName); m->bindParamS(3, ebuildVersion); m->execute(false); - // Prune packages - auto pp = dbc->modify(sql::maintenance::packagePrune.getSql()); - pp->bindParamS(0, categoryName); - pp->execute(); - // Prune categories - dbc->modify(sql::maintenance::categoryPrune.getSql())->execute(); + catsDeleteFrom.insert(categoryName); } } } diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h index a337e8b..2e92217 100644 --- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h +++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h @@ -28,6 +28,7 @@ namespace Gentoo { DB::ModifyCommandPtr depInsert; std::set ebuildIds; + std::set catsDeleteFrom; }; } } -- cgit v1.2.3