From: Zac Medico Date: Wed, 23 May 2007 00:28:36 +0000 (-0000) Subject: Lock $PKGDIR/Packages during population so that it won't get out of sync if another... X-Git-Tag: v2.2_pre1~1385 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=704b6281b086a967748e43dee51ed74810faac92;p=portage.git 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 --- 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