File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -399,26 +399,22 @@ def get_reports_root() -> Path:
399399
400400
401401def _path_is_inside (child : Path , parent : Path ) -> bool :
402- try :
403- child .relative_to (parent )
404- except ValueError :
405- return False
406- return child != parent
402+ return child != parent and child .is_relative_to (parent )
407403
408404
409405def clean_output_dir (output_dir : Path , console : Console ) -> None :
410- reports_root = get_reports_root ().expanduser ().absolute ()
406+ reports_root = get_reports_root ().expanduser ().resolve ()
411407 clean_target = output_dir .expanduser ().resolve ()
412408 if not _path_is_inside (clean_target , reports_root ):
413409 raise ValueError (
414410 f"Refusing to clean output outside repo reports/: { clean_target } "
415411 f"is not inside { reports_root } "
416412 )
417413
418- if output_dir .exists ():
414+ if clean_target .exists ():
419415 console .print (f"[yellow]WARN[/] wiping existing output directory { clean_target } " )
420- shutil .rmtree (output_dir )
421- output_dir .mkdir (parents = True , exist_ok = True )
416+ shutil .rmtree (clean_target )
417+ clean_target .mkdir (parents = True , exist_ok = True )
422418
423419
424420def create_run_output_dir (
You can’t perform that action at this time.
0 commit comments