avoid shredding empty files, also x/0

also cleaned up unused import and exception var
pull/14054/head
Brian Coca 9 years ago
parent 627dec716b
commit f26adcc7da

@ -71,7 +71,7 @@ try:
except ImportError:
pass
from ansible.compat.six import PY3, byte2int
from ansible.compat.six import PY3
from ansible.utils.unicode import to_unicode, to_bytes
HAS_ANY_PBKDF2HMAC = HAS_PBKDF2 or HAS_PBKDF2HMAC
@ -236,6 +236,8 @@ class VaultEditor:
"""
file_len = os.path.getsize(tmp_path)
if file_len > 0: # avoid work when file was empty
max_chunk_len = min(1024*1024*2, file_len)
passes = 3
@ -273,7 +275,7 @@ class VaultEditor:
try:
r = call(['shred', tmp_path])
except OSError as e:
except OSError:
# shred is not available on this system, or some other error occured.
r = 1

Loading…
Cancel
Save