Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions cwltool/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,28 +356,19 @@ def _relocate(src: str, dst: str) -> None:
return

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

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

if _action == "move":
_logger.debug("Moving %s to %s", src, dst)
if fs_access.isdir(src):
if fs_access.isdir(dst):
if len(fs_access.listdir(dst)) > 0:
# merge directories
for dir_entry in scandir(src):
_relocate(
dir_entry.path, fs_access.join(dst, dir_entry.name)
)
else:
os.rmdir(dst)
shutil.move(src, dst)
else:
shutil.move(src, dst)
if fs_access.isdir(src) and fs_access.isdir(dst):
# merge directories
for dir_entry in scandir(src):
_relocate(dir_entry.path, fs_access.join(dst, dir_entry.name))
else:
shutil.move(src, dst)

Expand Down
14 changes: 0 additions & 14 deletions tests/symlinks.cwl

This file was deleted.

20 changes: 4 additions & 16 deletions tests/test_relocate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

from .util import get_data, needs_docker

from io import StringIO
if sys.version_info[0] < 3:
from StringIO import StringIO
else:
from io import StringIO


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


def test_symlinks_with_absolute_paths(tmp_path: Path) -> None:
"""Confirm that absolute paths in Directory types don't cause problems."""
assert (
main(
[
"--debug",
f"--outdir={tmp_path}/result",
f"--tmpdir-prefix={tmp_path}/tmp",
get_data("tests/symlinks.cwl"),
]
)
== 0
)


@needs_docker
def test_for_conflict_file_names(tmp_path: Path) -> None:
stream = StringIO()
Expand Down