Change the NamedTemporaryFile() usage to mkstemp(), stupid API
authorJames Antill <james@and.org>
Thu, 9 Oct 2008 17:42:39 +0000 (13:42 -0400)
committerJames Antill <james@and.org>
Thu, 9 Oct 2008 17:42:39 +0000 (13:42 -0400)
createrepo/yumbased.py

index 3cd0cfef692a97fdabf964f44a22c17b0c60a70e..60568e3ee6f6d05e2f4118da95a860dc7e5146ad 100644 (file)
@@ -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