From 704b6281b086a967748e43dee51ed74810faac92 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 23 May 2007 00:28:36 +0000 Subject: [PATCH] Lock $PKGDIR/Packages during population so that it won't get out of sync if another process updates it. svn path=/main/trunk/; revision=6587 --- pym/portage/dbapi/bintree.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 27331ba37..59fe9a5db 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -361,6 +361,18 @@ class binarytree(object): def populate(self, getbinpkgs=0, getbinpkgsonly=0): "populates the binarytree" + from portage.locks import lockfile, unlockfile + pkgindex_lock = None + try: + if not self._all_directory and os.access(self.pkgdir, os.W_OK): + pkgindex_lock = lockfile(os.path.join(self.pkgdir, "Packages"), + wantnewlockfile=1) + self._populate(getbinpkgs, getbinpkgsonly) + finally: + if pkgindex_lock: + unlockfile(pkgindex_lock) + + def _populate(self, getbinpkgs, getbinpkgsonly): if (not os.path.isdir(self.pkgdir) and not getbinpkgs): return 0 -- 2.26.2