mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Re-add files.rename call instead of os.rename
This commit is contained in:
parent
acf2d51440
commit
01132c305c
@ -6,7 +6,6 @@ from __future__ import absolute_import
|
||||
|
||||
# Import python libs
|
||||
import contextlib
|
||||
import errno
|
||||
import logging
|
||||
import hashlib
|
||||
import os
|
||||
@ -23,6 +22,7 @@ import salt.payload
|
||||
import salt.transport
|
||||
import salt.fileserver
|
||||
import salt.utils
|
||||
import salt.utils.files
|
||||
import salt.utils.templates
|
||||
import salt.utils.url
|
||||
import salt.utils.gzip_util
|
||||
@ -612,20 +612,7 @@ class Client(object):
|
||||
dest_tmp = "{0}.part".format(dest)
|
||||
with salt.utils.fopen(dest_tmp, 'wb') as destfp:
|
||||
destfp.write(query['handle'].body)
|
||||
# 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)
|
||||
salt.utils.files.rename(dest_tmp, dest)
|
||||
return dest
|
||||
except HTTPError as exc:
|
||||
raise MinionError('HTTP error {0} reading {1}: {3}'.format(
|
||||
|
Loading…
Reference in New Issue
Block a user