[web] fix os.rename usage on windows when destination exists
os.rename on windows will raise OSError (or WindowsError subclass) when if
destination file already exists.
Also check that exception is EEXIST.
There is an attempt to fix in f6ba947c but using IOError instead of OSError.
Closes #14214794
--- a/cubicweb/web/propertysheet.py Wed Jan 25 14:28:20 2017 +0100
+++ b/cubicweb/web/propertysheet.py Tue Feb 21 10:12:47 2017 +0100
@@ -19,6 +19,7 @@
+import errno
import re
import os
import os.path as osp
@@ -109,7 +110,9 @@
stream.write(content)
try:
os.rename(tmpfile, cachefile)
- except IOError:
+ except OSError as err:
+ if err.errno != errno.EEXIST:
+ raise
# Under windows, os.rename won't overwrite an existing file
os.unlink(cachefile)
os.rename(tmpfile, cachefile)