From d88de04e301cbe5383e88505ea133f07a659fcbd Mon Sep 17 00:00:00 2001 From: James Antill Date: Wed, 8 Oct 2008 12:42:24 -0400 Subject: [PATCH] Fix parallel updates to the cachedir, thx to Michael Schwendt for spotting it --- createrepo/yumbased.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 -- 2.34.1