From 1846fe42607682ac9e792c6ec1675cbe3b44af4f Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Fri, 20 Jul 2018 08:26:15 -0500 Subject: [PATCH] Copy default prefix into place even if files are already present there Steam cloud sync places save files into pfx/ before proton is ever invoked. Previously we would assume the prefix is valid if pfx/ exists and run wine, which lead to very broken prefixes. Instead we should check for files that cloud sync will never create (user.reg) and merge the default prefix into any existing prefix tree. --- proton | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/proton b/proton index b8718664..13e08d8e 100755 --- a/proton +++ b/proton @@ -45,6 +45,28 @@ def makedirs(path): #already exists pass +def real_copy(src, dst): + if os.path.islink(src): + os.symlink(os.readlink(src), dst) + else: + shutil.copy(src,dst) + +def mergedirs(src, dst): + for src_dir, dirs, files in os.walk(src): + dst_dir = src_dir.replace(src, dst, 1) + if not os.path.exists(dst_dir): + os.makedirs(dst_dir) + for dir_ in dirs: + src_file = os.path.join(src_dir, dir_) + dst_file = os.path.join(dst_dir, dir_) + if os.path.islink(src_file) and not os.path.exists(dst_file): + real_copy(src_file, dst_file) + for file_ in files: + src_file = os.path.join(src_dir, file_) + dst_file = os.path.join(dst_dir, file_) + if not os.path.exists(dst_file): + real_copy(src_file, dst_file) + if not ("STEAM_COMPAT_DATA_PATH" in os.environ): log("No compat data path?") sys.exit(1) @@ -140,9 +162,9 @@ else: prefix_lock = FileLock(os.environ["STEAM_COMPAT_DATA_PATH"] + "/pfx.lock", timeout=-1) with prefix_lock: - if not os.path.isdir(prefix): + if not os.path.exists(prefix + "/user.reg"): #copy default prefix into place - shutil.copytree(basedir + "/dist/share/default_pfx", prefix, symlinks=True) + mergedirs(basedir + "/dist/share/default_pfx", prefix) version_file = os.environ["STEAM_COMPAT_DATA_PATH"] + "/version" if os.path.exists(version_file):