From 578dd5473e79e1e13922d18cbfdc01b6c1e7b5d7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kalinowski Date: Wed, 6 Dec 2023 17:38:31 +0400 Subject: [PATCH] Closing file descriptor provided by mkstemp --- b2/console_tool.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/b2/console_tool.py b/b2/console_tool.py index d304f0d81..2f99f56c7 100644 --- a/b2/console_tool.py +++ b/b2/console_tool.py @@ -1638,11 +1638,14 @@ def get_local_output_filepath( # Default permissions are: readable and writable by this user only, executable by noone. # This "temporary" file is not automatically removed, but still created in the safest way possible. - _handle, output_filepath_str = tempfile.mkstemp( + fd_handle, output_filepath_str = tempfile.mkstemp( prefix=file_name, suffix=file_extension, dir=output_directory, ) + # Close the handle, so the file is not locked. + # This file is no longer 100% "safe", but that's acceptable. + os.close(fd_handle) # "Normal" file created by Python has readable for everyone, writable for user only. # We change the permissions, to match the default ones.