88from datetime import datetime
99from config_manager import ConfigManager
1010import logging
11-
1211class ProtonManager :
1312 def __init__ (self ):
1413 self .protons_dir = ConfigManager .protons_dir
@@ -17,35 +16,31 @@ def __init__(self):
1716 self .available_official_stable_cache = None
1817 self .available_official_exp_cache = None
1918 self .cache_time = 0
20- self .cache_duration = 3600 # 1 hour
21-
19+ self .cache_duration = 3600 # 1 hour
2220 def refresh_cache_if_needed (self ):
2321 if time .time () - self .cache_time > self .cache_duration :
2422 self .available_ge_cache = self .get_available_ge ()
2523 self .available_official_stable_cache = self .get_available_official (stable = True )
2624 self .available_official_exp_cache = self .get_available_official (stable = False )
2725 self .cache_time = time .time ()
28-
2926 def get_installed_protons (self ):
3027 protons = []
3128 for d in os .listdir (self .protons_dir ):
3229 if os .path .isdir (os .path .join (self .protons_dir , d )):
3330 proton_path = os .path .join (self .protons_dir , d )
3431 version = d
35- proton_type = 'GE' if d .startswith ('GE-Proton' ) else 'Official'
32+ proton_type = 'GE' if d .startswith ('GE-Proton' ) else 'Experimental' if 'experimental' in d . lower () else ' Official'
3633 install_date = datetime .fromtimestamp (os .path .getctime (proton_path )).strftime ('%Y-%m-%d' )
3734 update_info = self .check_update (version , proton_type )
3835 status = 'Update Available' if update_info else 'Installed'
3936 protons .append ({'version' : version , 'type' : proton_type , 'date' : install_date , 'status' : status })
4037 return sorted (protons , key = lambda x : x ['version' ])
41-
4238 def get_proton_path (self , version ):
4339 base = os .path .join (self .protons_dir , version )
4440 for root , dirs , files in os .walk (base ):
4541 if 'proton' in files :
4642 return os .path .join (root , 'proton' )
4743 raise Exception (f"Proton binary not found in { version } " )
48-
4944 def _version_key (self , version ):
5045 version = version .replace ('GE-Proton' , '' ).replace ('Proton-' , '' )
5146 parts = []
@@ -69,7 +64,6 @@ def convert_part(part):
6964 except ValueError :
7065 return part
7166 return [convert_part (part ) for part in parts ]
72-
7367 def get_available_ge (self ):
7468 if self .available_ge_cache is not None :
7569 return self .available_ge_cache
@@ -91,7 +85,6 @@ def get_available_ge(self):
9185 print ("Failed to fetch GE protons after retries, returning empty list" )
9286 self .available_ge_cache = []
9387 return []
94-
9588 def get_available_official (self , stable = True ):
9689 if stable and self .available_official_stable_cache is not None :
9790 return self .available_official_stable_cache
@@ -125,7 +118,6 @@ def get_available_official(self, stable=True):
125118 else :
126119 self .available_official_exp_cache = []
127120 return []
128-
129121 def install_proton (self , version , proton_type , progress_callback = None ):
130122 try :
131123 repo = 'GloriousEggroll/proton-ge-custom' if proton_type == 'GE' else 'ValveSoftware/Proton'
@@ -192,7 +184,6 @@ def install_proton(self, version, proton_type, progress_callback=None):
192184 logging .error (f"Error installing { proton_type } proton { version } : { e } " )
193185 print (f"Error installing { proton_type } proton { version } : { e } " )
194186 return False , str (e )
195-
196187 def install_custom_tar (self , tar_path , version , progress_callback = None ):
197188 try :
198189 extract_dir = os .path .join (self .protons_dir , version )
@@ -226,7 +217,6 @@ def install_custom_tar(self, tar_path, version, progress_callback=None):
226217 logging .error (f"Error installing custom tar: { e } " )
227218 print (f"Error installing custom tar: { e } " )
228219 return False , str (e )
229-
230220 def install_custom_folder (self , src_folder , version ):
231221 try :
232222 dest = os .path .join (self .protons_dir , version )
@@ -240,7 +230,6 @@ def install_custom_folder(self, src_folder, version):
240230 logging .error (f"Error installing custom folder: { e } " )
241231 print (f"Error installing custom folder: { e } " )
242232 return False , str (e )
243-
244233 def remove_proton (self , version ):
245234 path = os .path .join (self .protons_dir , version )
246235 if not os .path .exists (path ):
@@ -253,18 +242,16 @@ def remove_proton(self, version):
253242 logging .error (f"Error removing proton: { e } " )
254243 print (f"Error removing proton: { e } " )
255244 return False
256-
257245 def check_update (self , version , proton_type ):
258246 self .refresh_cache_if_needed ()
259247 if proton_type == 'GE' :
260248 available = self .available_ge_cache
261- if available and available [0 ] != version :
262- return ('GE' , available [0 ])
263249 elif proton_type == 'Official' :
264- available_stable = self .available_official_stable_cache
265- available_exp = self .available_official_exp_cache
266- available = available_stable + available_exp
267- if available and available [0 ] != version :
268- new_type = 'Official' if available [0 ] in available_stable else 'Experimental'
269- return (new_type , available [0 ])
250+ available = self .available_official_stable_cache
251+ elif proton_type == 'Experimental' :
252+ available = self .available_official_exp_cache
253+ else :
254+ return None
255+ if available and available [0 ] != version :
256+ return (proton_type , available [0 ])
270257 return None
0 commit comments