diff options
author | Gábor Németh <homar@riseup.net> | 2023-03-06 16:19:14 +0100 |
---|---|---|
committer | Gábor Németh <homar@riseup.net> | 2023-11-22 11:05:28 +0100 |
commit | bd7c126e3fb1b94e76e0e632c657cea854586844 (patch) | |
tree | e7e5140d1857d155a187f6392cf458c0237f6858 /apt-private | |
parent | 6ba6b29e37a7e7b867a88f1d74e7dcfd7f83c30e (diff) |
Add 'dist-clean' command to remove packages and list files
We assume all files in the 'listsdir' are candidates. Keep only files
ending with Release, Release.gpg, and InRelease.
Closes: #959093
Diffstat (limited to 'apt-private')
-rw-r--r-- | apt-private/private-download.cc | 23 | ||||
-rw-r--r-- | apt-private/private-download.h | 2 |
2 files changed, 20 insertions, 5 deletions
diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc index eddb901d0..b271ec03f 100644 --- a/apt-private/private-download.cc +++ b/apt-private/private-download.cc @@ -304,9 +304,20 @@ bool DoChangelog(CommandLine &CmdL) } /*}}}*/ -// DoClean - Remove download archives /*{{{*/ +// DoClean - Remove download archives /*{{{*/ bool DoClean(CommandLine &) { + return DoDistClean(false); +} + /*}}}*/ +// DoDistClean - Remove download archives and lists /*{{{*/ +bool DoDistClean(CommandLine &) +{ + return DoDistClean(true); +} +// DoDistClean - the worker +bool DoDistClean(bool ListsToo) +{ std::string const archivedir = _config->FindDir("Dir::Cache::archives"); std::string const listsdir = _config->FindDir("Dir::state::lists"); @@ -315,23 +326,25 @@ bool DoClean(CommandLine &) std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache"); std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache"); std::cout << "Del " << archivedir << "* " << archivedir << "partial/*"<< std::endl - << "Del " << listsdir << "partial/*" << std::endl - << "Del " << pkgcache << " " << srcpkgcache << std::endl; + << "Del " << listsdir << "partial/*" << (ListsToo ? " *_{Packages,Sources}{,.diff_Index}" : "") << std::endl + << "Del " << pkgcache << " " << srcpkgcache << std::endl; return true; } pkgAcquire Fetcher; if (archivedir.empty() == false && FileExists(archivedir) == true && - Fetcher.GetLock(archivedir) == true) + Fetcher.GetLock(archivedir) == true) { Fetcher.Clean(archivedir); Fetcher.Clean(archivedir + "partial/"); } if (listsdir.empty() == false && FileExists(listsdir) == true && - Fetcher.GetLock(listsdir) == true) + Fetcher.GetLock(listsdir) == true) { Fetcher.Clean(listsdir + "partial/"); + if (ListsToo) + Fetcher.CleanLists(listsdir); } pkgCacheFile::RemoveCaches(); diff --git a/apt-private/private-download.h b/apt-private/private-download.h index d829e8b24..918828241 100644 --- a/apt-private/private-download.h +++ b/apt-private/private-download.h @@ -33,6 +33,8 @@ APT_PUBLIC bool DoDownload(CommandLine &CmdL); APT_PUBLIC bool DoChangelog(CommandLine &CmdL); APT_PUBLIC bool DoClean(CommandLine &CmdL); +APT_PUBLIC bool DoDistClean(CommandLine &CmdL); +bool DoDistClean(bool ListsToo); APT_PUBLIC bool DoAutoClean(CommandLine &CmdL); #endif |