File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -282,12 +282,13 @@ def extract_zipped_paths(path):
282282 return path
283283
284284 # we have a valid zip archive and a valid member of that archive
285- tmp = tempfile .gettempdir ()
286- extracted_path = os .path .join (tmp , member .split ("/" )[- 1 ])
287- if not os .path .exists (extracted_path ):
288- # use read + write to avoid the creating nested folders, we only want the file, avoids mkdir racing condition
289- with atomic_open (extracted_path ) as file_handler :
290- file_handler .write (zip_file .read (member ))
285+ suffix = os .path .splitext (member .split ("/" )[- 1 ])[- 1 ]
286+ fd , extracted_path = tempfile .mkstemp (suffix = suffix )
287+ try :
288+ os .write (fd , zip_file .read (member ))
289+ finally :
290+ os .close (fd )
291+
291292 return extracted_path
292293
293294
You can’t perform that action at this time.
0 commit comments