@@ -69,6 +69,14 @@ def __init__(self, output_path, output_url, copy_function=None):
6969 self .copy_function = copy_function
7070
7171 def _do_store (self , output ):
72+ """Copy output to final storage location.
73+
74+ - Create output directory
75+ - Check available file space
76+ - Create output file name, taking care of possible duplicates
77+ - Copy / link output in work directory to output directory
78+ - Return store type, output path and output URL
79+ """
7280 import platform
7381 import math
7482 import tempfile
@@ -78,6 +86,11 @@ def _do_store(self, output):
7886
7987 request_uuid = output .uuid or uuid .uuid1 ()
8088
89+ # Create a target folder for each request
90+ target = os .path .join (self .target , str (request_uuid ))
91+ if not os .path .exists (target ):
92+ os .makedirs (target )
93+
8194 # st.blksize is not available in windows, skips the validation on windows
8295 if platform .system () != 'Windows' :
8396 file_block_size = os .stat (file_name ).st_blksize
@@ -91,11 +104,6 @@ def _do_store(self, output):
91104 if avail_size < actual_file_size :
92105 raise NotEnoughStorage ('Not enough space in {} to store {}' .format (self .target , file_name ))
93106
94- # create a target folder for each request
95- target = os .path .join (self .target , str (request_uuid ))
96- if not os .path .exists (target ):
97- os .makedirs (target )
98-
99107 # build output name
100108 output_name , suffix = _build_output_name (output )
101109 # build tempfile in case of duplicates
@@ -116,7 +124,7 @@ def _do_store(self, output):
116124 url = self .url ("{}/{}" .format (request_uuid , just_file_name ))
117125 LOGGER .info ('File output URI: {}' .format (url ))
118126
119- return ( STORE_TYPE .PATH , output_name , url )
127+ return STORE_TYPE .PATH , output_name , url
120128
121129 @staticmethod
122130 def copy (src , dst , copy_function = None ):
@@ -134,7 +142,7 @@ def copy(src, dst, copy_function=None):
134142 try :
135143 os .link (src , dst )
136144 except Exception :
137- LOGGER .warn ("Could not create hardlink. Fallback to copy." )
145+ LOGGER .warning ("Could not create hardlink. Fallback to copy." )
138146 FileStorage .copy (src , dst )
139147 else :
140148 shutil .copy2 (src , dst )
0 commit comments