diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-12-14 03:21:20 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-12-14 03:21:20 +0100 |
commit | dffc17ba835b6bf782fe553d338b6a921c6de7bf (patch) | |
tree | ac162b8d0b85f98d1ca0537171bc157064d4df72 /apt-private/private-download.cc | |
parent | 27e4c1664a93bdce20de62a984e51d56671690ce (diff) |
non-existing directories don't need to be cleaned
Trying to clean up directories which do not exist seems rather silly if
you think about it, so let apt think about it and stop it.
Depends a bit on the caller if this is fixing anything for them as they
might try to acquire a lock or doing other clever things as apt does.
Closes: 807477
Diffstat (limited to 'apt-private/private-download.cc')
-rw-r--r-- | apt-private/private-download.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc index 40312d0c8..5cdcf6038 100644 --- a/apt-private/private-download.cc +++ b/apt-private/private-download.cc @@ -309,12 +309,18 @@ bool DoClean(CommandLine &) } pkgAcquire Fetcher; - Fetcher.GetLock(archivedir); - Fetcher.Clean(archivedir); - Fetcher.Clean(archivedir + "partial/"); + if (archivedir.empty() == false && FileExists(archivedir) == true) + { + Fetcher.GetLock(archivedir); + Fetcher.Clean(archivedir); + Fetcher.Clean(archivedir + "partial/"); + } - Fetcher.GetLock(listsdir); - Fetcher.Clean(listsdir + "partial/"); + if (listsdir.empty() == false && FileExists(listsdir) == true) + { + Fetcher.GetLock(listsdir); + Fetcher.Clean(listsdir + "partial/"); + } pkgCacheFile::RemoveCaches(); @@ -338,11 +344,15 @@ bool DoClean(CommandLine &) }; bool DoAutoClean(CommandLine &) { + std::string const archivedir = _config->FindDir("Dir::Cache::Archives"); + if (FileExists(archivedir) == false) + return true; + // Lock the archive directory FileFd Lock; if (_config->FindB("Debug::NoLocking",false) == false) { - int lock_fd = GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"); + int lock_fd = GetLock(flCombine(archivedir, "lock")); if (lock_fd < 0) return _error->Error(_("Unable to lock the download directory")); Lock.Fd(lock_fd); @@ -354,7 +364,7 @@ bool DoAutoClean(CommandLine &) LogCleaner Cleaner; - return Cleaner.Go(_config->FindDir("Dir::Cache::archives"),*Cache) && - Cleaner.Go(_config->FindDir("Dir::Cache::archives") + "partial/",*Cache); + return Cleaner.Go(archivedir, *Cache) && + Cleaner.Go(flCombine(archivedir, "partial/"), *Cache); } /*}}}*/ |