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

handle unsupported file operations #1544

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
15 changes: 11 additions & 4 deletions cwltool/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,17 @@ def create_file_and_add_volume(
file_literal.write(contents)
if not host_outdir_tgt:
self.append_volume(runtime, new_file, volume.target, writable=writable)
if writable:
ensure_writable(host_outdir_tgt or new_file)
else:
ensure_non_writable(host_outdir_tgt or new_file)
try:
if writable:
ensure_writable(host_outdir_tgt or new_file)
else:
ensure_non_writable(host_outdir_tgt or new_file)
except PermissionError as err:
_logger.warning(
"Encountered permission error trying to modify "
f"{host_outdir_tgt or new_file}:\n{err}"
"\nProceeding with caution."
)
return host_outdir_tgt or new_file

def add_volumes(
Expand Down
21 changes: 19 additions & 2 deletions cwltool/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,14 @@ def _relocate(src: str, dst: str) -> None:
for dir_entry in scandir(src):
_relocate(dir_entry.path, fs_access.join(dst, dir_entry.name))
else:
shutil.move(src, dst)
try:
shutil.move(src, dst)
except (PermissionError, OSError, shutil.Error):
# handle filesystems that don't support mode/attr changes
try:
shutil.move(src, dst, copy_function=shutil.copyfile)
except:
pass

elif _action == "copy":
_logger.debug("Copying %s to %s", src, dst)
Expand All @@ -384,7 +391,17 @@ def _relocate(src: str, dst: str) -> None:
os.unlink(dst)
shutil.copytree(src, dst)
else:
shutil.copy2(src, dst)
try:
shutil.copy2(src, dst)
except (PermissionError, OSError, shutil.Error):
# handle filesystems that don't support mode/attr changes
if os.path.isdir(dst):
shutil.copyfile(src, os.path.join(dst, os.path.basename(src)))
else:
try:
shutil.copyfile(src, dst)
except:
pass

def _realpath(
ob: CWLObjectType,
Expand Down