From 6e821c774fce67e35cedc2d193853c9333a1922f Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 12 May 2020 11:12:38 +0200 Subject: [PATCH] proton: Double-check to avoid locking, if unnecessary --- proton | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/proton b/proton index 33b80043..f39c2b15 100755 --- a/proton +++ b/proton @@ -107,11 +107,15 @@ class Proton: def path(self, d): return self.base_dir + d + def need_tarball_extraction(self): + '''Checks if the proton_dist tarball archive must be extracted. Returns true if extraction is needed, false otherwise''' + return not os.path.exists(self.dist_dir) or \ + not os.path.exists(self.path("dist/version")) or \ + not filecmp.cmp(self.version_file, self.path("dist/version")) + def extract_tarball(self): with self.dist_lock: - if not os.path.exists(self.dist_dir) or \ - not os.path.exists(self.path("dist/version")) or \ - not filecmp.cmp(self.version_file, self.path("dist/version")): + if self.need_tarball_extraction(): if os.path.exists(self.dist_dir): shutil.rmtree(self.dist_dir) tar = None @@ -126,10 +130,14 @@ class Proton: tar.close() try_copy(self.version_file, self.dist_dir) + def missing_default_prefix(self): + '''Check if the default prefix dir is missing. Returns true if missing, false if present''' + return not os.path.isdir(self.default_pfx_dir) + def make_default_prefix(self): with self.dist_lock: local_env = dict(g_session.env) - if not os.path.isdir(self.default_pfx_dir): + if self.missing_default_prefix(): #make default prefix local_env["WINEPREFIX"] = self.default_pfx_dir local_env["WINEDEBUG"] = "-all" @@ -670,7 +678,8 @@ if __name__ == "__main__": g_proton = Proton(os.path.dirname(sys.argv[0])) - g_proton.extract_tarball() + if g_proton.need_tarball_extraction(): + g_proton.extract_tarball() g_compatdata = CompatData(os.environ["STEAM_COMPAT_DATA_PATH"]) @@ -678,7 +687,8 @@ if __name__ == "__main__": g_session.init_wine() - g_proton.make_default_prefix() + if g_proton.missing_default_prefix(): + g_proton.make_default_prefix() g_session.init_session()