summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp9
-rw-r--r--gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h4
-rw-r--r--gentoobrowse-api/service/sql/maintenance/packagePrune.sql1
3 files changed, 9 insertions, 5 deletions
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
index 35a1bbf..0799b5a 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp
@@ -173,12 +173,13 @@ namespace Gentoo {
dbc->patchTable(&t);
}
}
- if (!catsDeleteFrom.empty()) {
+ if (!packagesToPrune.empty()) {
bool any = false;
- for(const auto & categoryName : catsDeleteFrom) {
+ for(const auto & catPkg : packagesToPrune) {
// Prune packages
auto pp = sql::maintenance::packagePrune.modify(dbc);
- pp->bindParamS(0, categoryName);
+ pp->bindParamS(0, catPkg.first);
+ pp->bindParamS(1, catPkg.second);
any |= pp->execute();
}
if (any) {
@@ -278,7 +279,7 @@ namespace Gentoo {
m->bindParamS(2, packageName);
m->bindParamS(3, ebuildVersion);
m->execute(false);
- catsDeleteFrom.insert(categoryName);
+ packagesToPrune.insert({ categoryName, packageName });
}
}
}
diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
index 471a7d7..c232933 100644
--- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
+++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.h
@@ -35,7 +35,9 @@ namespace Gentoo {
DB::ModifyCommandPtr useInsert;
DB::ModifyCommandPtr archInsert;
Utils::EntityWhereFilter<int64_t> ebuildIds;
- std::set<std::string> catsDeleteFrom;
+ typedef std::pair<std::string, std::string> CategoryPackage;
+ typedef std::set<CategoryPackage> PackagesToPrune;
+ PackagesToPrune packagesToPrune;
};
}
}
diff --git a/gentoobrowse-api/service/sql/maintenance/packagePrune.sql b/gentoobrowse-api/service/sql/maintenance/packagePrune.sql
index 510ed75..5dbb568 100644
--- a/gentoobrowse-api/service/sql/maintenance/packagePrune.sql
+++ b/gentoobrowse-api/service/sql/maintenance/packagePrune.sql
@@ -2,6 +2,7 @@ DELETE FROM gentoobrowse.packages p
USING gentoobrowse.categories c
WHERE p.categoryid = c.categoryid
AND c.name = ?
+AND p.name = ?
AND NOT EXISTS (
SELECT FROM gentoobrowse.ebuilds e
WHERE p.packageid = e.packageid)