@@ -228,9 +228,9 @@ def get_this_release_tuple(self) -> tuple[int, ...] | None:
228
228
return None
229
229
return tuple (int (x ) for x in version_match .groups ())
230
230
231
- def get_latest_release_version (self ) -> tuple [str , tuple [int , ...]] | tuple [None , None ]:
231
+ def fetch_latest_version (self ) -> tuple [str , tuple [int , ...]] | tuple [None , None ]:
232
232
"""
233
- Gets the version of the latest release.
233
+ Fetches the version of the latest release from github .
234
234
235
235
Should be called in a thread, as this makes a blocking HTTP request.
236
236
@@ -260,6 +260,29 @@ def get_latest_release_version(self) -> tuple[str, tuple[int, ...]] | tuple[None
260
260
unrealsdk .logging .dev_warning (traceback .format_exc ())
261
261
return None , None
262
262
263
+ def get_latest_cached_version (self ) -> tuple [str , tuple [int , ...]] | tuple [None , None ]:
264
+ """
265
+ Gets the version of the latest release from our cached setting.
266
+
267
+ Returns:
268
+ A tuple of the latest version name and version tuple, or None and None if unknown.
269
+ """
270
+ try :
271
+ name = self .latest_version_option .value
272
+ if name is None :
273
+ raise ValueError
274
+
275
+ match = RE_MANAGER_VERSION .match (name )
276
+ if match is None :
277
+ raise ValueError
278
+
279
+ return name , tuple (int (x ) for x in match .groups ())
280
+
281
+ except Exception : # noqa: BLE001
282
+ self .latest_version_option .value = None
283
+ self .save_settings ()
284
+ return None , None
285
+
263
286
def perform_version_check (self ) -> None :
264
287
"""
265
288
Checks if there's a newer version, and updates the options appropriately.
@@ -271,16 +294,20 @@ def perform_version_check(self) -> None:
271
294
unrealsdk .logging .warning ("Skipping SDK update check since current version is unknown" )
272
295
return
273
296
297
+ fetch_new_version = False
274
298
try :
275
299
next_check_time = datetime .fromisoformat (self .next_version_check_time_option .value )
276
- if next_check_time > datetime .now (UTC ):
277
- # Not time yet
278
- return
300
+ if next_check_time < datetime .now (UTC ):
301
+ fetch_new_version = True
279
302
except ValueError :
280
- # If we failed to parse the option, assume we need a new check
281
- pass
303
+ # If we failed to parse the option, assume we need to re-fetch
304
+ fetch_new_version = True
305
+
306
+ if fetch_new_version :
307
+ latest_version_name , latest_version_tuple = self .fetch_latest_version ()
308
+ else :
309
+ latest_version_name , latest_version_tuple = self .get_latest_cached_version ()
282
310
283
- latest_version_name , latest_version_tuple = self .get_latest_release_version ()
284
311
if latest_version_name is None or latest_version_tuple is None :
285
312
return
286
313
0 commit comments