Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 9529:e61e7b3e46d0
util.rename: do not abort if os.unlink fails (issue1840)
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Tue, 06 Oct 2009 10:45:23 +0200 |
parents | b2d65ee49a72 |
children | ba8a86d86fd6 b6b0c42739e9 |
comparison
equal
deleted
inserted
replaced
9528:314fc589b313 | 9529:e61e7b3e46d0 |
---|---|
442 return temp | 442 return temp |
443 raise IOError, (errno.EEXIST, "No usable temporary filename found") | 443 raise IOError, (errno.EEXIST, "No usable temporary filename found") |
444 | 444 |
445 temp = tempname(dst) | 445 temp = tempname(dst) |
446 os.rename(dst, temp) | 446 os.rename(dst, temp) |
447 os.unlink(temp) | 447 try: |
448 os.unlink(temp) | |
449 except: | |
450 # Some rude AV-scanners on Windows may cause the unlink to | |
451 # fail. Not aborting here just leaks the temp file, whereas | |
452 # aborting at this point may leave serious inconsistencies. | |
453 # Ideally, we would notify the user here. | |
454 pass | |
448 os.rename(src, dst) | 455 os.rename(src, dst) |
449 | 456 |
450 def unlink(f): | 457 def unlink(f): |
451 """unlink and remove the directory if it is empty""" | 458 """unlink and remove the directory if it is empty""" |
452 os.unlink(f) | 459 os.unlink(f) |