From 817828ec72acad36d9cebc00f5703b17166aa22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis=20Mos=C4=81ns?= Date: Fri, 1 Feb 2019 01:02:36 +0200 Subject: [PATCH] proton: When copying ignore EPERM error --- proton | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/proton b/proton index 15b54af6..2da9755e 100755 --- a/proton +++ b/proton @@ -8,6 +8,7 @@ import filecmp import json import os import shutil +import errno import struct import subprocess import sys @@ -81,7 +82,7 @@ def upgrade_pfx(old_ver): log("Removing newer prefix") if old_proton_ver == "3.7" and not os.path.exists(os.environ["STEAM_COMPAT_DATA_PATH"] + "/tracked_files"): #proton 3.7 did not generate tracked_files, so copy it into place first - shutil.copy(basedir + "/proton_3.7_tracked_files", os.environ["STEAM_COMPAT_DATA_PATH"] + "/tracked_files") + try_copy(basedir + "/proton_3.7_tracked_files", os.environ["STEAM_COMPAT_DATA_PATH"] + "/tracked_files") remove_tracked_files(os.environ["STEAM_COMPAT_DATA_PATH"]) return @@ -107,11 +108,21 @@ def makedirs(path): #already exists pass +def try_copy(src, dst): + try: + shutil.copy(src, dst) + 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) + else: + raise + def real_copy(src, dst): if os.path.islink(src): os.symlink(os.readlink(src), dst) else: - shutil.copy(src,dst) + try_copy(src, dst) def mergedirs(src, dst, tracked_files): for src_dir, dirs, files in os.walk(src): @@ -156,7 +167,7 @@ with dist_lock: tar = tarfile.open(basedir + "/proton_dist.tar.gz", mode="r:gz") tar.extractall(path=basedir + "/dist") tar.close() - shutil.copy(basedir + "/version", basedir + "/dist/") + try_copy(basedir + "/version", basedir + "/dist/") env = dict(os.environ) dlloverrides = {} @@ -324,16 +335,16 @@ with prefix_lock: dstfile = dst + "Steam/" + f if os.path.isfile(dstfile): os.remove(dstfile) - shutil.copy(steamdir + "/legacycompat/" + f, dstfile) + try_copy(steamdir + "/legacycompat/" + f, dstfile) #copy openvr files into place dst = prefix + "/drive_c/vrclient/bin/" makedirs(dst) - shutil.copy(basedir + "/dist/lib/wine/fakedlls/vrclient.dll", dst) - shutil.copy(basedir + "/dist/lib64/wine/fakedlls/vrclient_x64.dll", dst) + try_copy(basedir + "/dist/lib/wine/fakedlls/vrclient.dll", dst) + try_copy(basedir + "/dist/lib64/wine/fakedlls/vrclient_x64.dll", dst) - shutil.copy(basedir + "/dist/lib/wine/dxvk/openvr_api_dxvk.dll", prefix + "/drive_c/windows/syswow64/") - shutil.copy(basedir + "/dist/lib64/wine/dxvk/openvr_api_dxvk.dll", prefix + "/drive_c/windows/system32/") + try_copy(basedir + "/dist/lib/wine/dxvk/openvr_api_dxvk.dll", prefix + "/drive_c/windows/syswow64/") + try_copy(basedir + "/dist/lib64/wine/dxvk/openvr_api_dxvk.dll", prefix + "/drive_c/windows/system32/") #parse linux openvr config and present it in win32 format to the app. #logic from openvr's CVRPathRegistry_Public::GetPaths