Skip to content

Commit

Permalink
Merge pull request #47565 from rallytime/bp-47440
Browse files Browse the repository at this point in the history
Back-port #47440 to 2018.3
  • Loading branch information
Nicole Thomas committed May 10, 2018
2 parents 17e0fdc + 7c43417 commit b22657f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions salt/fileclient.py
Expand Up @@ -13,6 +13,7 @@
import shutil
import ftplib
from tornado.httputil import parse_response_start_line, HTTPHeaders, HTTPInputError
import salt.utils.atomicfile

# Import salt libs
from salt.exceptions import (
Expand Down Expand Up @@ -1166,7 +1167,11 @@ def get_file(self,
destdir = os.path.dirname(dest)
if not os.path.isdir(destdir):
if makedirs:
os.makedirs(destdir)
try:
os.makedirs(destdir)
except OSError as exc:
if exc.errno != errno.EEXIST: # ignore if it was there already
raise
else:
return False
# We need an open filehandle here, that's why we're not using a
Expand Down Expand Up @@ -1221,7 +1226,7 @@ def get_file(self,
# 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, 'wb+')
fn_ = salt.utils.atomicfile.atomic_open(dest, 'wb+')
if data.get('gzip', None):
data = salt.utils.gzip_util.uncompress(data['data'])
else:
Expand Down
1 change: 1 addition & 0 deletions salt/utils/thin.py
Expand Up @@ -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',
Expand Down

0 comments on commit b22657f

Please sign in to comment.