mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Don't use os.rename() to overwrite file, causes errors on Windows
This commit is contained in:
parent
2819b85373
commit
5aff1aeb9e
@ -6,6 +6,7 @@ from __future__ import absolute_import
|
||||
|
||||
# Import python libs
|
||||
import contextlib
|
||||
import errno
|
||||
import logging
|
||||
import hashlib
|
||||
import os
|
||||
@ -623,6 +624,19 @@ class Client(object):
|
||||
else:
|
||||
destfp.close()
|
||||
destfp = None
|
||||
# Can't just do an os.rename() here, this results in a
|
||||
# WindowsError being raised when the destination path exists on
|
||||
# a Windows machine. Have to remove the file.
|
||||
try:
|
||||
os.remove(dest)
|
||||
except OSError as exc:
|
||||
if exc.errno != errno.ENOENT:
|
||||
raise MinionError(
|
||||
'Error: Unable to remove {0}: {1}'.format(
|
||||
dest,
|
||||
exc.strerror
|
||||
)
|
||||
)
|
||||
os.rename(dest_tmp, dest)
|
||||
return dest
|
||||
except HTTPError as exc:
|
||||
|
Loading…
Reference in New Issue
Block a user