diff .hgtags @ 13206:650314ed845d stable

windows.rename: eliminate temp name race (issue2571) On Windows, os.rename reliably raises OSError with errno.EEXIST if the destination already exists (even on shares served by Samba). Windows does *not* silently overwrite the destination of a rename. So there is no need to first call os.path.exists on the chosen temp path. Trusting os.path.exists is actually harmful, since using it enables the following racy sequence of actions: 1) os.path.exists(temp) returns False 2) some evil other process creates a file with name temp 3) os.rename(dst, temp) now fails because temp has been taken Not using os.path.exists and directly trying os.rename(dst, temp) eliminates this race.
author Adrian Buehlmann <adrian@cadifra.com>
date Mon, 27 Dec 2010 01:12:31 +0100
parents ad3acb1ff4ac
children 6264b6dedf11
line wrap: on
line diff