From 129dce66aee854eacde4a35ec888d5d19683190f Mon Sep 17 00:00:00 2001 From: Mandrew0822 <110215582+Mandrew0822@users.noreply.github.com> Date: Fri, 27 Dec 2024 12:56:31 -0500 Subject: [PATCH] Updated try_copyfile function Added better error handling to 'try_copyfile' as I felt it would be easier to debug if something went awry --- proton | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/proton b/proton index cdeb9cd28..236d26650 100755 --- a/proton +++ b/proton @@ -250,12 +250,25 @@ def try_copyfile(src, dst): if file_exists(dst, follow_symlinks=False): os.remove(dst) copyfile(src, dst) + except FileNotFoundError as e: + log(f"File not found error while copying from \"{src}\" to \"{dst}\": {e.strerror}") except PermissionError as e: if e.errno == errno.EPERM: - #be forgiving about permissions errors; if it's a real problem, things will explode later anyway - log('Error while copying to \"' + dst + '\": ' + e.strerror) + log(f"Permission error while copying to \"{dst}\": {e.strerror}") else: + log(f"Permission error with code {e.errno} while copying to \"{dst}\": {e.strerror}") raise + except OSError as e: + if e.errno in (errno.ENOSPC, errno.EDQUOT): + log(f"Disk space error while copying from \"{src}\" to \"{dst}\": {e.strerror}") + elif e.errno == errno.EIO: + log(f"I/O error while copying from \"{src}\" to \"{dst}\": {e.strerror}") + else: + log(f"OS error while copying from \"{src}\" to \"{dst}\": {e.strerror}") + raise + except Exception as e: + log(f"Unexpected error while copying from \"{src}\" to \"{dst}\": {str(e)}") + raise def getmtimestr(*path_fragments): path = os.path.join(*path_fragments)