diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-11-09 19:04:54 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-11-09 21:45:55 +0100 |
commit | 7e04a6bf23d857db60afd2ec3d0f4a8271b1c597 (patch) | |
tree | 81bb72a0619512369349cf82827cfc2ac2c55fe0 /cmdline/apt-get.cc | |
parent | bf6ac7ca615922c23d1f3cf1963efc5be9c23e32 (diff) | |
download | apt-7e04a6bf23d857db60afd2ec3d0f4a8271b1c597.tar.gz |
use pkgAcquire::GetLock instead of own code
Do the same with less code in apt-get. This especially ensures that the
lock file (and the parent directories) exist before we are trying to
lock. It also means that clean now creates the directories if they are
missing so we returned to a proper clean state now.
Git-Dch: Ignore
Diffstat (limited to 'cmdline/apt-get.cc')
-rw-r--r-- | cmdline/apt-get.cc | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index a9053bdfd..eab792264 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -558,30 +558,12 @@ static bool DoClean(CommandLine &) return true; } - bool const NoLocking = _config->FindB("Debug::NoLocking",false); - // Lock the archive directory - FileFd Lock; - if (NoLocking == false) - { - int lock_fd = GetLock(archivedir + "lock"); - if (lock_fd < 0) - return _error->Error(_("Unable to lock directory %s"), archivedir.c_str()); - Lock.Fd(lock_fd); - } - pkgAcquire Fetcher; + Fetcher.GetLock(archivedir); 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.GetLock(listsdir); Fetcher.Clean(listsdir + "partial/"); pkgCacheFile::RemoveCaches(); |