@@ -480,12 +480,17 @@ def _create_dataset_cache_directory(dataset_id):
480480 str
481481 Path of the created dataset cache directory.
482482 """
483- dataset_cache_dir = os .path .join (config .get_cache_directory (), "datasets" , str (dataset_id ))
484- try :
485- os .makedirs (dataset_cache_dir )
486- except (OSError , IOError ):
487- # TODO add debug information!
483+ dataset_cache_dir = os .path .join (
484+ config .get_cache_directory (),
485+ "datasets" ,
486+ str (dataset_id ),
487+ )
488+ if os .path .exists (dataset_cache_dir ) and os .path .isdir (dataset_cache_dir ):
488489 pass
490+ elif os .path .exists (dataset_cache_dir ) and not os .path .isdir (dataset_cache_dir ):
491+ raise ValueError ('Dataset cache dir exists but is not a directory!' )
492+ else :
493+ os .makedirs (dataset_cache_dir )
489494 return dataset_cache_dir
490495
491496
@@ -498,13 +503,10 @@ def _remove_dataset_cache_dir(did_cache_dir):
498503 ----------
499504 """
500505 try :
501- os . rmdir (did_cache_dir )
506+ shutil . rmtree (did_cache_dir )
502507 except (OSError , IOError ):
503- try :
504- shutil .rmtree (did_cache_dir )
505- except (OSError , IOError ):
506- raise ValueError ('Cannot remove faulty dataset cache directory %s.'
507- 'Please do this manually!' % did_cache_dir )
508+ raise ValueError ('Cannot remove faulty dataset cache directory %s.'
509+ 'Please do this manually!' % did_cache_dir )
508510
509511
510512def _create_dataset_from_description (description , features , qualities , arff_file ):
0 commit comments