util.rename: do not abort if os.unlink fails (issue1840)
authorAdrian Buehlmann <adrian@cadifra.com>
Tue, 06 Oct 2009 10:45:23 +0200
changeset 9529 e61e7b3e46d0
parent 9528 314fc589b313
child 9530 ba8a86d86fd6
child 9531 a2f36a082449
child 9544 b6b0c42739e9
util.rename: do not abort if os.unlink fails (issue1840)
mercurial/util.py
--- a/mercurial/util.py	Mon Oct 05 22:01:08 2009 +0200
+++ b/mercurial/util.py	Tue Oct 06 10:45:23 2009 +0200
@@ -444,7 +444,14 @@
 
         temp = tempname(dst)
         os.rename(dst, temp)
-        os.unlink(temp)
+        try:
+            os.unlink(temp)
+        except:
+            # Some rude AV-scanners on Windows may cause the unlink to
+            # fail. Not aborting here just leaks the temp file, whereas
+            # aborting at this point may leave serious inconsistencies.
+            # Ideally, we would notify the user here.
+            pass
         os.rename(src, dst)
 
 def unlink(f):