summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-11-12 16:59:08 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2017-11-12 16:59:08 +0000
commit4472a810b52ad8b762a2e70be732cb9e3d369974 (patch)
tree6ed0fa059a156e17b68c69046ad6d7bc27d49965
parentDon't try to be too clever when processing updates, as there is no guarantee ... (diff)
downloadgentoobrowse-api-0.9.2.tar.bz2
gentoobrowse-api-0.9.2.tar.xz
gentoobrowse-api-0.9.2.zip
More fine grained package pruninggentoobrowse-api-0.9.2
-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)