From dffc17ba835b6bf782fe553d338b6a921c6de7bf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 14 Dec 2015 03:21:20 +0100 Subject: 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 --- apt-pkg/clean.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'apt-pkg/clean.cc') diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index 8e6bd6255..fe57c26a2 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -38,6 +38,11 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) if(Dir == "/") return _error->Error(_("Clean of %s is not supported"), Dir.c_str()); + // non-existing directories are always clean + // we do not check for a directory explicitly to support symlinks + if (FileExists(Dir) == false) + return true; + DIR *D = opendir(Dir.c_str()); if (D == 0) return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); -- cgit v1.2.3