Lock $PKGDIR/Packages during population so that it won't get out of sync if another...
authorZac Medico <zmedico@gentoo.org>
Wed, 23 May 2007 00:28:36 +0000 (00:28 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 23 May 2007 00:28:36 +0000 (00:28 -0000)
svn path=/main/trunk/; revision=6587

pym/portage/dbapi/bintree.py

index 27331ba3705efdc11732b0cc3e6037d30154ef4c..59fe9a5db0740fdc8eca3890af66dfc200d9d2f3 100644 (file)
@@ -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