addressed feedback

This commit is contained in:
Kirill Timofeev 2018-05-03 13:29:16 -07:00 committed by rallytime
parent 1abe05207c
commit 7c43417d46
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19
2 changed files with 3 additions and 6 deletions

View file

@ -13,7 +13,7 @@ import string
import shutil
import ftplib
from tornado.httputil import parse_response_start_line, HTTPHeaders, HTTPInputError
import uuid
import salt.utils.atomicfile
# Import salt libs
from salt.exceptions import (
@ -1163,7 +1163,6 @@ class RemoteClient(Client):
load['gzip'] = gzip
fn_ = None
dest_tmp = None
if dest:
destdir = os.path.dirname(dest)
if not os.path.isdir(destdir):
@ -1223,12 +1222,11 @@ class RemoteClient(Client):
saltenv,
cachedir=cachedir) as cache_dest:
dest = cache_dest
dest_tmp = "{0}/{1}".format(os.path.dirname(dest), str(uuid.uuid4()))
# If a directory was formerly cached at this path, then
# remove it to avoid a traceback trying to write the file
if os.path.isdir(dest):
salt.utils.files.rm_rf(dest)
fn_ = salt.utils.files.fopen(dest_tmp, 'wb+')
fn_ = salt.utils.atomicfile.atomic_open(dest, 'wb+')
if data.get('gzip', None):
data = salt.utils.gzip_util.uncompress(data['data'])
else:
@ -1259,8 +1257,6 @@ class RemoteClient(Client):
if fn_:
fn_.close()
if dest_tmp:
os.rename(dest_tmp, dest)
log.info(
'Fetching file from saltenv \'%s\', ** done ** \'%s\'',
saltenv, path

View file

@ -464,6 +464,7 @@ def gen_min(cachedir, extra_mods='', overwrite=False, so_mods='',
'salt/__init__.py',
'salt/utils',
'salt/utils/__init__.py',
'salt/utils/atomicfile.py',
'salt/utils/validate',
'salt/utils/validate/__init__.py',
'salt/utils/validate/path.py',