mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add overwrite option so the extraction of the archive can be always performed.
This commit is contained in:
parent
e6958f7f15
commit
91b42578b2
1 changed files with 14 additions and 1 deletions
|
@ -12,6 +12,7 @@ import logging
|
|||
import os
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import stat
|
||||
import tarfile
|
||||
from contextlib import closing
|
||||
|
@ -140,6 +141,7 @@ def extracted(name,
|
|||
enforce_toplevel=True,
|
||||
enforce_ownership_on=None,
|
||||
archive_format=None,
|
||||
overwrite=False,
|
||||
**kwargs):
|
||||
'''
|
||||
.. versionadded:: 2014.1.0
|
||||
|
@ -497,6 +499,10 @@ def extracted(name,
|
|||
.. _zipfile: https://docs.python.org/2/library/zipfile.html
|
||||
.. _xz-utils: http://tukaani.org/xz/
|
||||
|
||||
overwrite
|
||||
If archive was already extracted, then setting this to True will
|
||||
extract it all over again.
|
||||
|
||||
**Examples**
|
||||
|
||||
1. tar with lmza (i.e. xz) compression:
|
||||
|
@ -897,7 +903,14 @@ def extracted(name,
|
|||
# already need to catch an OSError to cover edge cases where the minion is
|
||||
# running as a non-privileged user and is trying to check for the existence
|
||||
# of a path to which it does not have permission.
|
||||
extraction_needed = False
|
||||
|
||||
extraction_needed = overwrite
|
||||
|
||||
if extraction_needed:
|
||||
destination = os.path.join(name, contents['top_level_dirs'][0])
|
||||
if os.path.exists(destination):
|
||||
shutil.rmtree(destination)
|
||||
|
||||
try:
|
||||
if_missing_path_exists = os.path.exists(if_missing)
|
||||
except TypeError:
|
||||
|
|
Loading…
Add table
Reference in a new issue