Skip to content

Commit a094bef

Browse files
committed
workaround: create parent directories on file creation
This is a workaround only: the parent directories should be created before the files on a higher level
1 parent af3768f commit a094bef

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cwltool/docker.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ def add_volumes(self, pathmapper, runtime, secret_store=None):
218218
if not vol.staged:
219219
continue
220220
host_outdir_tgt = None # type: Optional[Text]
221-
if vol.target.startswith(container_outdir+"/"):
221+
if vol.target.startswith(container_outdir + "/"):
222222
host_outdir_tgt = os.path.join(
223223
host_outdir, vol.target[len(container_outdir)+1:])
224+
224225
if vol.type in ("File", "Directory"):
225226
if not vol.resolved.startswith("_:"):
226227
_check_docker_machine_path(docker_windows_path_adjust(
@@ -244,7 +245,8 @@ def add_volumes(self, pathmapper, runtime, secret_store=None):
244245
elif vol.type == "WritableDirectory":
245246
if vol.resolved.startswith("_:"):
246247
if host_outdir_tgt:
247-
os.makedirs(host_outdir_tgt, 0o0755)
248+
if not os.path.exists(host_outdir_tgt):
249+
os.makedirs(host_outdir_tgt, 0o0755)
248250
else:
249251
raise WorkflowException(
250252
"Unable to compute host_outdir_tgt for "
@@ -268,6 +270,9 @@ def add_volumes(self, pathmapper, runtime, secret_store=None):
268270
else:
269271
contents = vol.resolved
270272
if host_outdir_tgt:
273+
dirname = os.path.dirname(host_outdir_tgt)
274+
if not os.path.exists(dirname):
275+
os.makedirs(dirname, 0o0755)
271276
with open(host_outdir_tgt, "wb") as file_literal:
272277
file_literal.write(contents.encode("utf-8"))
273278
else:

0 commit comments

Comments
 (0)