File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 2323# SOFTWARE.
2424
2525
26+ from genericpath import exists
2627from pathlib import Path
2728from tempfile import TemporaryDirectory
28- from os import urandom , replace
29+ from os import urandom , remove
30+ from shutil import move , rmtree
2931import binascii
3032import zipfile
3133
@@ -83,6 +85,9 @@ def download(url,
8385 on_error = on_download_error )
8486
8587 if is_zip :
88+ if dst .exists ():
89+ rmtree (dst )
90+
8691 # Extract data to destination directory
8792 HTTPDownloader ._extract_content (tmp_data_path ,
8893 dst ,
@@ -91,7 +96,10 @@ def download(url,
9196 on_finish = on_unzip_finish ,
9297 on_error = on_unzip_error )
9398 else :
94- replace (tmp_data_path , dst )
99+ if dst .exists ():
100+ remove (dst )
101+
102+ move (tmp_data_path , dst )
95103
96104 @staticmethod
97105 def _save_content (url ,
You can’t perform that action at this time.
0 commit comments