OS rename raises an exception on Windows
This patch checks the exception raises by os.rename() on Windows and provide the same behavior than Linux. This patch is related to issue #37, issue 5. This patch sets closes the issue 37. closes #37
This commit is contained in:
parent
c305f47e84
commit
1a0c29a00e
@ -302,7 +302,15 @@ class BaseFolder:
|
||||
|
||||
with open(uidfilename + ".tmp", "wt") as uidfile:
|
||||
uidfile.write("%d\n" % newval)
|
||||
os.rename(uidfilename + ".tmp", uidfilename)
|
||||
|
||||
# This is weird, os.rename on Windows raises an exception,
|
||||
# But not in Linux. In linux the file is overwritten.
|
||||
try:
|
||||
os.rename(uidfilename + ".tmp", uidfilename)
|
||||
except WindowsError:
|
||||
os.remove(uidfilename)
|
||||
os.rename(uidfilename + ".tmp", uidfilename)
|
||||
|
||||
self._base_saved_uidvalidity = newval
|
||||
|
||||
def get_uidvalidity(self):
|
||||
|
Loading…
Reference in New Issue
Block a user