Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid relink if not having permissions #1045

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 9 additions & 4 deletions cwltool/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,18 @@ def relink_initialworkdir(pathmapper, # type: PathMapper
("WritableFile", "WritableDirectory"))):
if not vol.target.startswith(container_outdir):
# this is an input file written outside of the working
# directory, so therefor ineligable for being an output file.
# directory, so therefore ineligible for being an output file.
# Thus, none of our business
continue
host_outdir_tgt = os.path.join(
host_outdir, vol.target[len(container_outdir) + 1:])
# Try to remove and relink only if remove is permitted
if os.path.islink(host_outdir_tgt) \
or os.path.isfile(host_outdir_tgt):
os.remove(host_outdir_tgt)
try:
os.remove(host_outdir_tgt)
except:
pass
elif os.path.isdir(host_outdir_tgt) \
and not vol.resolved.startswith("_:"):
shutil.rmtree(host_outdir_tgt)
Expand All @@ -157,8 +161,9 @@ def relink_initialworkdir(pathmapper, # type: PathMapper
shutil.copy(vol.resolved, host_outdir_tgt)
elif vol.type in ("Directory", "WritableDirectory"):
copytree_with_merge(vol.resolved, host_outdir_tgt)
elif not vol.resolved.startswith("_:"):
os.symlink(vol.resolved, host_outdir_tgt)
elif not vol.resolved.startswith("_:") \
and not os.path.exists(host_outdir_tgt):
os.symlink(vol.resolved, host_outdir_tgt)


class JobBase(with_metaclass(ABCMeta, HasReqsHints)):
Expand Down