summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-05-23 00:28:36 +0000
committerZac Medico <zmedico@gentoo.org>2007-05-23 00:28:36 +0000
commit704b6281b086a967748e43dee51ed74810faac92 (patch)
treeddc214cc5921df39e25e1a928fc9fbf19a320bce
parent94e3f8fe18ff3bd86b4ef4cbb474e4c52994edc7 (diff)
downloadportage-704b6281b086a967748e43dee51ed74810faac92.tar.gz
portage-704b6281b086a967748e43dee51ed74810faac92.tar.bz2
portage-704b6281b086a967748e43dee51ed74810faac92.zip
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
-rw-r--r--pym/portage/dbapi/bintree.py12
1 files changed, 12 insertions, 0 deletions
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