|
|
@@ -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;
|