[Rpm-metadata] createrepo/yumbased.py

James Antill james at osuosl.org
Thu Oct 9 15:17:45 UTC 2008


 createrepo/yumbased.py |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit d88de04e301cbe5383e88505ea133f07a659fcbd
Author: James Antill <james at and.org>
Date:   Wed Oct 8 12:42:24 2008 -0400

    Fix parallel updates to the cachedir, thx to Michael Schwendt for spotting it

diff --git a/createrepo/yumbased.py b/createrepo/yumbased.py
index adb6017..3cd0cfe 100644
--- a/createrepo/yumbased.py
+++ b/createrepo/yumbased.py
@@ -28,6 +28,7 @@ from yum.sqlutils import executeSQL
 from rpmUtils.transaction import initReadOnlyTransaction
 from rpmUtils.miscutils import flagToString, stringToVersion
 import utils
+import tempfile
 
 class CreateRepoPackage(YumLocalPackage):
     def __init__(self, ts, package):
@@ -72,9 +73,13 @@ class CreateRepoPackage(YumLocalPackage):
              
         else:
             checksum = misc.checksum('sha', self.localpath)
-            csumo = open(csumfile, 'w')
+
+            #  This is atomic cache creation via. rename, so we can have two
+            # tasks using the same cachedir ... mash does this.
+            csumo = tempfile.NamedTemporaryFile(mode='w', dir=self.crp_cachedir)
             csumo.write(checksum)
             csumo.close()
+            os.rename(csumo.name, csumfile)
         
         self._checksum = checksum
 


More information about the Rpm-metadata mailing list