Skip to content

Commit 5883109

Browse files
authored
Revert "better handle symlinks in Directories (#1462)" (#1483)
This reverts commit 23acadf.
1 parent 0358a41 commit 5883109

File tree

3 files changed

+10
-45
lines changed

3 files changed

+10
-45
lines changed

cwltool/process.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -356,28 +356,19 @@ def _relocate(src: str, dst: str) -> None:
356356
return
357357

358358
# If the source is not contained in source_directories we're not allowed to delete it
359-
real_src = fs_access.realpath(src)
359+
src = fs_access.realpath(src)
360360
src_can_deleted = any(
361-
os.path.commonprefix([p, real_src]) == p for p in source_directories
361+
os.path.commonprefix([p, src]) == p for p in source_directories
362362
)
363363

364364
_action = "move" if action == "move" and src_can_deleted else "copy"
365365

366366
if _action == "move":
367367
_logger.debug("Moving %s to %s", src, dst)
368-
if fs_access.isdir(src):
369-
if fs_access.isdir(dst):
370-
if len(fs_access.listdir(dst)) > 0:
371-
# merge directories
372-
for dir_entry in scandir(src):
373-
_relocate(
374-
dir_entry.path, fs_access.join(dst, dir_entry.name)
375-
)
376-
else:
377-
os.rmdir(dst)
378-
shutil.move(src, dst)
379-
else:
380-
shutil.move(src, dst)
368+
if fs_access.isdir(src) and fs_access.isdir(dst):
369+
# merge directories
370+
for dir_entry in scandir(src):
371+
_relocate(dir_entry.path, fs_access.join(dst, dir_entry.name))
381372
else:
382373
shutil.move(src, dst)
383374

tests/symlinks.cwl

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/test_relocate.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
from .util import get_data, needs_docker
88

9-
from io import StringIO
9+
if sys.version_info[0] < 3:
10+
from StringIO import StringIO
11+
else:
12+
from io import StringIO
1013

1114

1215
@needs_docker
@@ -15,21 +18,6 @@ def test_for_910() -> None:
1518
assert main([get_data("tests/wf/910.cwl")]) == 0
1619

1720

18-
def test_symlinks_with_absolute_paths(tmp_path: Path) -> None:
19-
"""Confirm that absolute paths in Directory types don't cause problems."""
20-
assert (
21-
main(
22-
[
23-
"--debug",
24-
f"--outdir={tmp_path}/result",
25-
f"--tmpdir-prefix={tmp_path}/tmp",
26-
get_data("tests/symlinks.cwl"),
27-
]
28-
)
29-
== 0
30-
)
31-
32-
3321
@needs_docker
3422
def test_for_conflict_file_names(tmp_path: Path) -> None:
3523
stream = StringIO()

0 commit comments

Comments
 (0)