Skip to content

Commit ca9ac72

Browse files
committed
adds check that you aren't trying to copy a directory into itself
1 parent 5c57f8b commit ca9ac72

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fileformats/core/fileset.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,10 @@ def hardlink_dir(src: Path, dest: Path) -> None:
15441544
for fspath, new_path in src_dest:
15451545
new_path.parent.mkdir(parents=True, exist_ok=True)
15461546
if fspath.is_dir():
1547+
if new_path.is_relative_to(fspath): # type: ignore[attr-defined]
1548+
raise ValueError(
1549+
f"Cannot copy directory {fspath} into itself at {new_path}"
1550+
)
15471551
copy_dir(fspath, new_path)
15481552
else:
15491553
try:

0 commit comments

Comments
 (0)