avoid shredding empty files, also x/0

also cleaned up unused import and exception var
pull/14214/head
Brian Coca 9 years ago
parent d56e2fb80e
commit 92579eb48f

@ -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