diff --git a/management/mail_log.py b/management/mail_log.py index 34bc7630..a641ef7d 100755 --- a/management/mail_log.py +++ b/management/mail_log.py @@ -72,9 +72,9 @@ def scan_files(collector): if not os.path.exists(fn): continue if fn[-3:] == '.gz': - tmp_file = tempfile.NamedTemporaryFile() - with gzip.open(fn, 'rb') as f: - shutil.copyfileobj(f, tmp_file) + with tempfile.NamedTemporaryFile(delete=False) as tmp_file: + with gzip.open(fn, 'rb') as f: + shutil.copyfileobj(f, tmp_file) if VERBOSE: print("Processing file", fn, "...")