Skip to content

Commit

Permalink
Closing file descriptor provided by mkstemp
Browse files Browse the repository at this point in the history
  • Loading branch information
kkalinowski-reef committed Dec 6, 2023
1 parent 0aff457 commit 578dd54
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion b2/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 578dd54

Please sign in to comment.