summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-09-27 20:09:44 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2014-09-27 20:09:44 +0200
commit20e6965ad6388b964b59b89c31ff8b81cbcb8f8c (patch)
treeb23b62ab13ba8ba74c86532dbf0dd575c8d48279 /cmdline
parent43acd01979039b248cb7f033b82e36d778d0ebec (diff)
cleanup partial directory of lists in apt-get clean
Not really the intended usecase for apt-get clean, but users expect it to help them in recovery and it can't really hurt as this directory should be empty if everything was fine and proper anyway. Closes: #762889
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-get.cc26
1 files changed, 20 insertions, 6 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 6d03c7eec..c8c3ca56b 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -549,30 +549,44 @@ static bool DoDSelectUpgrade(CommandLine &)
static bool DoClean(CommandLine &)
{
std::string const archivedir = _config->FindDir("Dir::Cache::archives");
- std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
- std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
+ std::string const listsdir = _config->FindDir("Dir::state::lists");
if (_config->FindB("APT::Get::Simulate") == true)
{
+ std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
+ std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
cout << "Del " << archivedir << "* " << archivedir << "partial/*"<< endl
+ << "Del " << listsdir << "partial/*" << endl
<< "Del " << pkgcache << " " << srcpkgcache << endl;
return true;
}
-
+
+ bool const NoLocking = _config->FindB("Debug::NoLocking",false);
// Lock the archive directory
FileFd Lock;
- if (_config->FindB("Debug::NoLocking",false) == false)
+ if (NoLocking == false)
{
int lock_fd = GetLock(archivedir + "lock");
if (lock_fd < 0)
- return _error->Error(_("Unable to lock the download directory"));
+ return _error->Error(_("Unable to lock directory %s"), archivedir.c_str());
Lock.Fd(lock_fd);
}
-
+
pkgAcquire Fetcher;
Fetcher.Clean(archivedir);
Fetcher.Clean(archivedir + "partial/");
+ if (NoLocking == false)
+ {
+ Lock.Close();
+ int lock_fd = GetLock(listsdir + "lock");
+ if (lock_fd < 0)
+ return _error->Error(_("Unable to lock directory %s"), listsdir.c_str());
+ Lock.Fd(lock_fd);
+ }
+
+ Fetcher.Clean(listsdir + "partial/");
+
pkgCacheFile::RemoveCaches();
return true;