mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Use temporary filename instead of output directly to the "thin.tgz"
This commit is contained in:
parent
d841164ae3
commit
2f90054fbe
@ -329,7 +329,6 @@ def _get_thintar_prefix(tarname):
|
||||
'''
|
||||
tfd, tmp_tarname = tempfile.mkstemp(dir=os.path.dirname(tarname), prefix=".thin-",
|
||||
suffix="." + os.path.basename(tarname).split(".", 1)[-1])
|
||||
os.write(tfd, salt.utils.stringutils.to_bytes(""))
|
||||
os.close(tfd)
|
||||
|
||||
return tmp_tarname
|
||||
@ -453,10 +452,11 @@ def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='',
|
||||
with salt.utils.files.fopen(pymap_cfg, 'wb') as fp_:
|
||||
fp_.write(_get_supported_py_config(tops=tops_py_version_mapping, extended_cfg=extended_cfg))
|
||||
|
||||
tmp_thintar = _get_thintar_prefix(thintar)
|
||||
if compress == 'gzip':
|
||||
tfp = tarfile.open(thintar, 'w:gz', dereference=True)
|
||||
tfp = tarfile.open(tmp_thintar, 'w:gz', dereference=True)
|
||||
elif compress == 'zip':
|
||||
tfp = zipfile.ZipFile(thintar, 'w', compression=zlib and zipfile.ZIP_DEFLATED or zipfile.ZIP_STORED)
|
||||
tfp = zipfile.ZipFile(tmp_thintar, 'w', compression=zlib and zipfile.ZIP_DEFLATED or zipfile.ZIP_STORED)
|
||||
tfp.add = tfp.write
|
||||
|
||||
try: # cwd may not exist if it was removed but salt was run from it
|
||||
|
Loading…
Reference in New Issue
Block a user