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

Updated try_copyfile function #8348

Open
wants to merge 1 commit into
base: proton_9.0
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
17 changes: 15 additions & 2 deletions proton
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down