feat(cleanup): add a maintenance page for unused and legacy packages
Leftovers pile up on a machine: dependencies that no installed package requires any more, and installs coming from the AUR or manual builds that the sync databases know nothing about. The new Nettoyage page lists both (orphans first, since they are the ones that can be removed in bulk), shows which provider reported each row, and frees the space held by the caches: paccache (or pacman -Sc) and flatpak's unused runtimes. Cleanup is an optional capability of IPackageManager, so providers that only install packages keep working unchanged. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
b8f8dc569f
commit
632cdf1dea
10 files changed
+750
-6
No files matched your search
@@ -24,6 +24,13 @@ struct PackageInfo {
|
||||
std::vector<std::string> providers;
|
||||
bool installed = false;
|
||||
bool updateAvailable = false;
|
||||
// Cleanup classification, filled by providers that report maintainable
|
||||
// leftovers (see IPackageManager::listCleanupCandidates): true when no
|
||||
// installed package requires this one, so it is safe to bulk-remove.
|
||||
bool orphan = false;
|
||||
// Short reason this row shows up as a cleanup candidate (e.g. "Orphelin",
|
||||
// "Étranger"), empty for regular packages.
|
||||
std::string cleanupReason;
|
||||
};
|
||||
|
||||
// Merge packages that share the same name (offered by several providers) into
|
||||
@@ -142,6 +149,42 @@ public:
|
||||
virtual std::vector<PackageInfo> listUpdates() = 0;
|
||||
virtual bool refresh(ProgressCallback progressCallback = nullptr) = 0;
|
||||
|
||||
// ---- Cleanup (optional) ----
|
||||
// Providers that can reclaim unused/legacy packages override these; the
|
||||
// defaults leave providers that only install packages working unchanged.
|
||||
|
||||
// Whether the provider can enumerate cleanup candidates at all.
|
||||
virtual bool canListCleanup() const { return false; }
|
||||
|
||||
// Packages a cleanup can reclaim: orphans (nothing installed requires
|
||||
// them) and legacy leftovers (installed from outside the sync
|
||||
// repositories, e.g. AUR or manual builds). Rows carry `orphan` and
|
||||
// `cleanupReason`.
|
||||
virtual std::vector<PackageInfo> listCleanupCandidates() { return {}; }
|
||||
|
||||
// Remove several packages in one operation (a single privileged command
|
||||
// instead of one per package). Defaults to a sequence of remove() calls.
|
||||
virtual bool removePackages(const std::vector<std::string>& packages,
|
||||
ProgressCallback progressCallback = nullptr) {
|
||||
bool success = true;
|
||||
for (const auto& name : packages) {
|
||||
success = remove(name, progressCallback) && success;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
// Whether cleanCache() actually has something to trim here, so the UI only
|
||||
// offers the action for providers that own a cache.
|
||||
virtual bool canCleanCache() const { return false; }
|
||||
|
||||
// Free the disk space held by the provider's caches (package cache,
|
||||
// unused runtimes...). Returns false when the cleanup failed; the reason is
|
||||
// then in lastError().
|
||||
virtual bool cleanCache(ProgressCallback progressCallback = nullptr) {
|
||||
(void)progressCallback;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the package manager is available on the system
|
||||
virtual bool isAvailable() const = 0;
|
||||
|
||||
|
||||
Reference in new issue
Block a user