Skip to content

Commit fd7db53

Browse files
authored
Files with identical basenames get staged to unique paths (#1853)
1 parent d7c4d48 commit fd7db53

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

cwltool/process.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ def stage_files(
264264
"File staging conflict, trying to stage both %s and %s to the same target %s"
265265
% (targets[entry.target].resolved, entry.resolved, entry.target)
266266
)
267-
267+
# refresh the items, since we may have updated the pathmapper due to file name clashes
268+
items = pathmapper.items() if not symlink else pathmapper.items_exclude_children()
268269
for key, entry in items:
269270
if not entry.staged:
270271
continue

tests/test_relocate.py

+20
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ def test_for_conflict_file_names(tmp_path: Path) -> None:
3333
out = json.loads(stream.getvalue())
3434
assert out["b1"]["basename"] == out["b2"]["basename"]
3535
assert out["b1"]["location"] != out["b2"]["location"]
36+
assert Path(out["b1"]["path"]).exists()
37+
assert Path(out["b2"]["path"]).exists()
38+
39+
40+
def test_for_conflict_file_names_nodocker(tmp_path: Path) -> None:
41+
stream = StringIO()
42+
43+
assert (
44+
main(
45+
["--debug", "--outdir", str(tmp_path), get_data("tests/wf/conflict.cwl")],
46+
stdout=stream,
47+
)
48+
== 0
49+
)
50+
51+
out = json.loads(stream.getvalue())
52+
assert out["b1"]["basename"] == out["b2"]["basename"]
53+
assert out["b1"]["location"] != out["b2"]["location"]
54+
assert Path(out["b1"]["path"]).exists()
55+
assert Path(out["b2"]["path"]).exists()
3656

3757

3858
def test_relocate_symlinks(tmp_path: Path) -> None:

tests/wf/conflict.cwl

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ $graph:
44
- class: CommandLineTool
55
id: makebzz
66
inputs: []
7+
baseCommand: touch
78
outputs:
89
bzz:
910
type: File
1011
outputBinding:
1112
glob: bzz
12-
requirements:
13-
ShellCommandRequirement: {}
14-
arguments: [{shellQuote: false, valueFrom: "touch bzz"}]
13+
arguments: [ bzz ]
1514
- class: Workflow
1615
id: main
1716
inputs: []

0 commit comments

Comments
 (0)