File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -807,6 +807,8 @@ def numreturn(a):
807807 except socket .timeout :
808808 pass
809809 if not buffer :
810+ if file_size == float ('+inf' ): # Prevent infinite downloading
811+ break
810812 if is_chunked and received_chunk == range_length :
811813 break
812814 elif not is_chunked and received == file_size : # Download finished
@@ -827,9 +829,10 @@ def numreturn(a):
827829 received , os .path .getsize (temp_filepath ), temp_filepath
828830 )
829831
830- if os .access (filepath , os .W_OK ):
832+ if os .access (filepath , os .W_OK ) and file_size != float ( 'inf' ) :
831833 # on Windows rename could fail if destination filepath exists
832- os .remove (filepath )
834+ # we should simply choose a new name instead of brutal os.remove(filepath)
835+ filepath = filepath + " (2)"
833836 os .rename (temp_filepath , filepath )
834837
835838
You can’t perform that action at this time.
0 commit comments