mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-01-13 15:18:13 +03:00
proton: Double-check to avoid locking, if unnecessary
This commit is contained in:
parent
c6a40b9947
commit
6e821c774f
18
proton
18
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,6 +678,7 @@ if __name__ == "__main__":
|
||||
|
||||
g_proton = Proton(os.path.dirname(sys.argv[0]))
|
||||
|
||||
if g_proton.need_tarball_extraction():
|
||||
g_proton.extract_tarball()
|
||||
|
||||
g_compatdata = CompatData(os.environ["STEAM_COMPAT_DATA_PATH"])
|
||||
@ -678,6 +687,7 @@ if __name__ == "__main__":
|
||||
|
||||
g_session.init_wine()
|
||||
|
||||
if g_proton.missing_default_prefix():
|
||||
g_proton.make_default_prefix()
|
||||
|
||||
g_session.init_session()
|
||||
|
Loading…
x
Reference in New Issue
Block a user