[Pkg-bazaar-commits] ./bzr/unstable r559: - AtomicFile must cope without destination file existing on

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:18:58 UTC 2009


------------------------------------------------------------
revno: 559
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Thu 2005-05-26 12:22:15 +1000
message:
  - AtomicFile must cope without destination file existing on 
    win32
    (patch from John A Meinel)
modified:
  bzrlib/atomicfile.py
-------------- next part --------------
=== modified file 'bzrlib/atomicfile.py'
--- a/bzrlib/atomicfile.py	2005-05-26 02:13:57 +0000
+++ b/bzrlib/atomicfile.py	2005-05-26 02:22:15 +0000
@@ -51,7 +51,13 @@
         
         self.f.close()
         if sys.platform == 'win32':
-            os.remove(self.realfilename)
+            # windows cannot rename over an existing file
+            try:
+                os.remove(self.realfilename)
+            except OSError, e:
+                import errno
+                if e.errno != errno.ENOENT:
+                    raise
         os.rename(self.tmpfilename, self.realfilename)
 
     def abort(self):



More information about the Pkg-bazaar-commits mailing list