[M5+] cargoxx add evicts stale auto-discovered overlay rows
This commit is contained in:
@@ -241,6 +241,28 @@ auto overlay_delete_recipe(OverlayState& state, const std::string& package,
|
||||
return {};
|
||||
}
|
||||
|
||||
auto overlay_evict_auto(OverlayState& state, const std::string& package)
|
||||
-> util::Result<void> {
|
||||
// `manual` rows are user-curated via `cargoxx linkdb add`; everything
|
||||
// else (`nix-probe`, `conan`, `vcpkg`, …) was synthesized by the
|
||||
// resolver from the current cargoxx logic and is safe to drop —
|
||||
// the next add will re-discover with the latest scanner.
|
||||
constexpr const char* SQL =
|
||||
"DELETE FROM recipes WHERE package = ? AND source != 'manual'";
|
||||
sqlite3* db = state.handle();
|
||||
sqlite3_stmt* stmt = nullptr;
|
||||
if (sqlite3_prepare_v2(db, SQL, -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
return std::unexpected(sqlite_error(db, "prepare evict"));
|
||||
}
|
||||
sqlite3_bind_text(stmt, 1, package.c_str(), -1, SQLITE_TRANSIENT);
|
||||
auto rc = sqlite3_step(stmt);
|
||||
sqlite3_finalize(stmt);
|
||||
if (rc != SQLITE_DONE) {
|
||||
return std::unexpected(sqlite_error(db, "step evict"));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
auto overlay_query(OverlayState& state, const std::string& package)
|
||||
-> util::Result<std::vector<OverlayRow>> {
|
||||
constexpr const char* SQL =
|
||||
@@ -380,6 +402,14 @@ auto Database::abort_provisional(const std::string& package,
|
||||
return detail::overlay_delete_recipe(*overlay_, package, version_range, source);
|
||||
}
|
||||
|
||||
auto Database::evict_auto_recipes(const std::string& package)
|
||||
-> util::Result<void> {
|
||||
if (auto ok = require_overlay(overlay_); !ok) {
|
||||
return std::unexpected(ok.error());
|
||||
}
|
||||
return detail::overlay_evict_auto(*overlay_, package);
|
||||
}
|
||||
|
||||
auto Database::set_libcxx_override(const std::string& package,
|
||||
const std::string& version_range,
|
||||
const std::string& source, bool value)
|
||||
|
||||
Reference in New Issue
Block a user