From 8f273390cc52ca9e46728e4202add824940eda30 Mon Sep 17 00:00:00 2001 From: Jeff Jasper Date: Tue, 26 Sep 2017 14:42:12 -0400 Subject: [PATCH 1/3] remove dir before copytree, use copy2 to keep metadata --- cwltool/process.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cwltool/process.py b/cwltool/process.py index 13e2161d0..9b769920b 100644 --- a/cwltool/process.py +++ b/cwltool/process.py @@ -279,9 +279,11 @@ def moveIt(src, dst): if src != dst: _logger.debug("Copying %s to %s", src, dst) if os.path.isdir(src): + if os.path.exists(dst): + shutil.rmtree(dst) shutil.copytree(src, dst) else: - shutil.copy(src, dst) + shutil.copy2(src, dst) outfiles = [] # type: List[Dict[Text, Any]] collectFilesAndDirs(outputObj, outfiles) From 01564561c2543e97029e3bb407563acf70b7c6ab Mon Sep 17 00:00:00 2001 From: Jeff Jasper Date: Tue, 26 Sep 2017 16:28:43 -0400 Subject: [PATCH 2/3] specify directory --- cwltool/process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cwltool/process.py b/cwltool/process.py index 9b769920b..b7fc00d05 100644 --- a/cwltool/process.py +++ b/cwltool/process.py @@ -279,7 +279,7 @@ def moveIt(src, dst): if src != dst: _logger.debug("Copying %s to %s", src, dst) if os.path.isdir(src): - if os.path.exists(dst): + if os.path.isdir(dst): shutil.rmtree(dst) shutil.copytree(src, dst) else: From 09dd4903a53f84557a9be788294e7cd4652b5e8a Mon Sep 17 00:00:00 2001 From: Jeff Jasper Date: Tue, 26 Sep 2017 16:44:00 -0400 Subject: [PATCH 3/3] cover scenario where files have same name as directory --- cwltool/process.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cwltool/process.py b/cwltool/process.py index b7fc00d05..1841ca728 100644 --- a/cwltool/process.py +++ b/cwltool/process.py @@ -281,6 +281,8 @@ def moveIt(src, dst): if os.path.isdir(src): if os.path.isdir(dst): shutil.rmtree(dst) + elif os.path.isfile(dst): + os.unlink(dst) shutil.copytree(src, dst) else: shutil.copy2(src, dst)