[Rpm-metadata] createrepo/yumbased.py

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


 createrepo/yumbased.py |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit e4edc4aa4d6446686c9c796c8d1996c6122b9a71
Author: James Antill <james at and.org>
Date:   Thu Oct 9 13:42:39 2008 -0400

    Change the NamedTemporaryFile() usage to mkstemp(), stupid API

diff --git a/createrepo/yumbased.py b/createrepo/yumbased.py
index 3cd0cfe..60568e3 100644
--- a/createrepo/yumbased.py
+++ b/createrepo/yumbased.py
@@ -76,10 +76,14 @@ class CreateRepoPackage(YumLocalPackage):
 
             #  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)
+            try:
+                (csumo, tmpfilename) = tempfile.mkstemp(dir=self.crp_cachedir)
+                csumo = os.fdopen(csumo, 'w', -1)
+                csumo.write(checksum)
+                csumo.close()
+                os.rename(tmpfilename, csumfile)
+            except:
+                pass
         
         self._checksum = checksum
 


More information about the Rpm-metadata mailing list