@@ -468,15 +468,17 @@ def _download_and_extract(url, extract_path=None):
468
468
extract_path = os .path .join (extract_path , "%s/" % file_name .split ("." )[0 ])
469
469
470
470
try :
471
- if not os .path .exists (extract_path ):
471
+ already_exists = os .path .exists (extract_path )
472
+ if not already_exists :
472
473
os .makedirs (extract_path )
473
474
zipfile .ZipFile (zip_file_name , "r" ).extractall (extract_path )
474
475
shutil .rmtree (dl_dir )
475
476
return extract_path
476
477
except zipfile .BadZipFile :
477
478
shutil .rmtree (dl_dir )
478
- if os .path .exists (extract_path ):
479
- shutil .rmtree (extract_path )
479
+ if not already_exists :
480
+ if os .path .exists (extract_path ):
481
+ shutil .rmtree (extract_path )
480
482
raise zipfile .BadZipFile (
481
483
"Could not unzip dataset. Please make sure the URL is valid."
482
484
)
@@ -546,7 +548,7 @@ def _load_tsc_dataset(
546
548
except zipfile .BadZipFile as e :
547
549
raise ValueError (
548
550
f"Invalid dataset name ={ name } is not available on extract path ="
549
- f"{ extract_path } . Nor is it available on { url } " ,
551
+ f"{ extract_path } nor is it available on { url } " ,
550
552
) from e
551
553
552
554
return _load_saved_dataset (
@@ -1342,7 +1344,7 @@ def load_classification(
1342
1344
try_zenodo = False
1343
1345
error_str = (
1344
1346
f"Invalid dataset name ={ name } that is not available on extract path "
1345
- f"={ extract_path } . Nor is it available on "
1347
+ f"={ extract_path } nor is it available on "
1346
1348
f"https://timeseriesclassification.com/ or zenodo."
1347
1349
)
1348
1350
try :
0 commit comments