mirror of https://github.com/fail2ban/fail2ban
Use tempfile contextmanager in with_tmpdir
parent
3c22ae161c
commit
5045f05107
|
@ -235,12 +235,8 @@ def with_tmpdir(f):
|
|||
"""
|
||||
@wraps(f)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
tmp = tempfile.mkdtemp(prefix="f2b-temp")
|
||||
try:
|
||||
with tempfile.TemporaryDirectory(prefix="f2b-temp") as tmp:
|
||||
return f(self, tmp, *args, **kwargs)
|
||||
finally:
|
||||
# clean up
|
||||
shutil.rmtree(tmp)
|
||||
return wrapper
|
||||
|
||||
def with_alt_time(f):
|
||||
|
|
Loading…
Reference in New Issue