From c05dcf5b057e2481b1210a8d92da91eeb59d28ff Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 26 Jul 2019 15:16:54 -0400 Subject: [PATCH] Remove fs_cleanup file_descriptor argument Signed-off-by: Roberto Rosario --- mayan/apps/storage/utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mayan/apps/storage/utils.py b/mayan/apps/storage/utils.py index 5cc27d0d82..07a0eeb041 100644 --- a/mayan/apps/storage/utils.py +++ b/mayan/apps/storage/utils.py @@ -22,13 +22,10 @@ def NamedTemporaryFile(*args, **kwargs): return tempfile.NamedTemporaryFile(*args, **kwargs) -def fs_cleanup(filename, file_descriptor=None, suppress_exceptions=True): +def fs_cleanup(filename, suppress_exceptions=True): """ - Tries to remove the given filename. Ignores non-existent files + Tries to remove the given filename. Ignores non-existent files. """ - if file_descriptor: - os.close(file_descriptor) - try: os.remove(filename) except OSError: @@ -63,6 +60,12 @@ def get_storage_subclass(dotted_path): def mkdtemp(*args, **kwargs): + """ + Creates a temporary directory in the most secure manner possible. + There are no race conditions in the directory’s creation. + The directory is readable, writable, and searchable only by the creating + user ID. + """ kwargs.update({'dir': setting_temporary_directory.value}) return tempfile.mkdtemp(*args, **kwargs)