mirror of
https://github.com/chenxiaolong/avbroot.git
synced 2026-07-03 14:05:11 +02:00
avbroot/util.py: open_output_file: Close file before unlinking on Windows
This fixes temporary files being left behind when interrupted on Windows. Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
This commit is contained in:
@@ -34,6 +34,10 @@ def open_output_file(path):
|
||||
|
||||
os.rename(f.name, path)
|
||||
except BaseException:
|
||||
if os.name == 'nt':
|
||||
# Windows does not allow deleting a file with handles open
|
||||
f.close()
|
||||
|
||||
os.unlink(f.name)
|
||||
raise
|
||||
|
||||
|
||||
Reference in New Issue
Block a user