diff options
Diffstat (limited to 'src/buildstream')
-rw-r--r-- | src/buildstream/utils.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py index 99c22d169..9591951e8 100644 --- a/src/buildstream/utils.py +++ b/src/buildstream/utils.py @@ -385,7 +385,11 @@ def safe_copy(src: str, dest: str, *, result: Optional[FileListResult] = None) - if e.errno != errno.ENOENT: raise UtilError("Failed to remove destination file '{}': {}".format(dest, e)) from e - shutil.copyfile(src, dest) + try: + shutil.copyfile(src, dest) + except (OSError, shutil.Error) as e: + raise UtilError("Failed to copy '{} -> {}': {}".format(src, dest, e)) from e + try: shutil.copystat(src, dest) except PermissionError: @@ -398,9 +402,6 @@ def safe_copy(src: str, dest: str, *, result: Optional[FileListResult] = None) - if result: result.failed_attributes.append(dest) - except shutil.Error as e: - raise UtilError("Failed to copy '{} -> {}': {}".format(src, dest, e)) from e - def safe_link(src: str, dest: str, *, result: Optional[FileListResult] = None, _unlink=False) -> None: """Try to create a hardlink, but resort to copying in the case of cross device links. |