Skip to content

Commit

Permalink
fix condition in copy_file when hitting PermissionError when copying …
Browse files Browse the repository at this point in the history
…read-only file
  • Loading branch information
boegel committed Sep 18, 2024
1 parent a3b26f6 commit 23b5b78
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2443,11 +2443,11 @@ def copy_file(path, target_path, force_in_dry_run=False):
# see https://bugs.python.org/issue24538
shutil.copy2(path, target_path)
_log.info("%s copied to %s", path, target_path)
# catch the more general OSError instead of PermissionError,
# since Python 2.7 doesn't support PermissionError
except OSError as err:
# catch the more general OSError instead of PermissionError, since python2 doesn't support
# PermissionError
if not os.stat(path).st_mode & stat.S_IWUSR:
# failure not due to read-only file
# if file is writable (not read-only), then we give up since it's not a simple permission error
if os.path.exists(target_path) and os.stat(target_path).st_mode & stat.S_IWUSR:
raise EasyBuildError("Failed to copy file %s to %s: %s", path, target_path, err)

pyver = LooseVersion(platform.python_version())
Expand Down

0 comments on commit 23b5b78

Please sign in to comment.