1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-01-23 12:37:05 +00:00

Fixed SIM115 (open-file-with-context-handler): Use a context manager for opening files

This commit is contained in:
Teal Dulcet 2025-01-12 07:10:31 -08:00
parent c59ff13c9f
commit f13ae569d0

View File

@ -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, "...")