@@ -475,13 +475,22 @@ def _get_extraction_path(self, path: Path, path_use_description: str) -> Path:
475
475
fs_path = self ._fs_path (path )
476
476
477
477
if fs_path .absolute_path .exists ():
478
- report = ExtractionProblem (
479
- path = str (fs_path .relative_path ),
480
- problem = f"Attempting to create a file that already exists through { path_use_description } " ,
481
- resolution = "Overwrite." ,
482
- )
483
- fs_path .absolute_path .unlink ()
484
- self .record_problem (report )
478
+ if fs_path .absolute_path .is_file ():
479
+ report = ExtractionProblem (
480
+ path = str (fs_path .relative_path ),
481
+ problem = f"Overwriting already existing file through { path_use_description } " ,
482
+ resolution = "Overwriting." ,
483
+ )
484
+ self .record_problem (report )
485
+ fs_path .absolute_path .unlink ()
486
+
487
+ elif fs_path .absolute_path .is_dir ():
488
+ report = ExtractionProblem (
489
+ path = str (fs_path .relative_path ),
490
+ problem = f"Attempting to create a directory that already exists through { path_use_description } " ,
491
+ resolution = "Ignore" ,
492
+ )
493
+ self .record_problem (report )
485
494
486
495
if not fs_path .is_safe :
487
496
report = PathTraversalProblem (
@@ -550,7 +559,7 @@ def mknod(self, path: Path, mode=0o600, device=0):
550
559
def _get_checked_link (self , src : Path , dst : Path ) -> Optional [_FSLink ]:
551
560
link = _FSLink (root = self .root , src = src , dst = dst )
552
561
553
- if link .src .absolute_path .exists ():
562
+ if link .dst .absolute_path .exists ():
554
563
self .record_problem (link .format_report ("File already exists." ))
555
564
return None
556
565
if not link .is_safe :
0 commit comments