File tree Expand file tree Collapse file tree 3 files changed +45
-10
lines changed Expand file tree Collapse file tree 3 files changed +45
-10
lines changed Original file line number Diff line number Diff line change @@ -356,19 +356,28 @@ def _relocate(src: str, dst: str) -> None:
356
356
return
357
357
358
358
# If the source is not contained in source_directories we're not allowed to delete it
359
- src = fs_access .realpath (src )
359
+ real_src = fs_access .realpath (src )
360
360
src_can_deleted = any (
361
- os .path .commonprefix ([p , src ]) == p for p in source_directories
361
+ os .path .commonprefix ([p , real_src ]) == p for p in source_directories
362
362
)
363
363
364
364
_action = "move" if action == "move" and src_can_deleted else "copy"
365
365
366
366
if _action == "move" :
367
367
_logger .debug ("Moving %s to %s" , 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 ))
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 )
372
381
else :
373
382
shutil .move (src , dst )
374
383
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env cwl-runner
2
+ cwlVersion: v1.0
3
+ class: CommandLineTool
4
+ inputs : []
5
+ baseCommand : [ bash, -c ]
6
+ arguments :
7
+ # - "mkdir foo; echo 42 > foo/bar; ln -s bar foo/baz"
8
+ - "mkdir foo; echo 42 > foo/bar; ln -s $PWD/foo/bar foo/baz"
9
+ # - "mkdir foo; ln -s $PWD/foo/bar foo/baz ; echo 42 > foo/bar"
10
+ outputs :
11
+ result:
12
+ type : Directory
13
+ outputBinding :
14
+ glob : foo
Original file line number Diff line number Diff line change 6
6
7
7
from .util import get_data , needs_docker
8
8
9
- if sys .version_info [0 ] < 3 :
10
- from StringIO import StringIO
11
- else :
12
- from io import StringIO
9
+ from io import StringIO
13
10
14
11
15
12
@needs_docker
@@ -18,6 +15,21 @@ def test_for_910() -> None:
18
15
assert main ([get_data ("tests/wf/910.cwl" )]) == 0
19
16
20
17
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
+
21
33
@needs_docker
22
34
def test_for_conflict_file_names (tmp_path : Path ) -> None :
23
35
stream = StringIO ()
You can’t perform that action at this time.
0 commit comments