1
0
mirror of https://github.com/lutris/lutris synced 2024-07-05 16:38:42 +00:00

Fix runtime not updating

This commit is contained in:
Mathieu Comandon 2024-03-18 12:01:03 -07:00
parent 6e8aecfef0
commit b8bf74c006
4 changed files with 16 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import urllib.error
import urllib.parse
import urllib.request
from collections import OrderedDict
from datetime import datetime
from gettext import gettext as _
from typing import Any, Dict, Optional, Tuple
@ -43,12 +44,16 @@ def get_runtime_versions_date_time_ago() -> str:
def check_stale_runtime_versions() -> bool:
"""True if runtime versions file that download_runtime_versions() creates
is missing or stale; if true we must call that function."""
"""Check if the runtime needs to be updated"""
try:
threshold = time.time() + 6 * 60 * 60 # 6 hours from now
modified_at = get_runtime_versions_date()
return threshold < modified_at
should_update_at = modified_at + 6 * 60 * 60
logger.debug(
"Modified at %s, will update after %s",
datetime.fromtimestamp(modified_at).strftime("%c"),
datetime.fromtimestamp(should_update_at).strftime("%c"),
)
return should_update_at < time.time()
except FileNotFoundError:
return True

View File

@ -1129,17 +1129,21 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
we can determine that there are updates to perform."""
def create_runtime_updater():
"""WTF"""
runtime_updater = RuntimeUpdater(force=force_updates)
component_updaters = runtime_updater.create_component_updaters()
return component_updaters, runtime_updater
def create_runtime_updater_cb(result, error):
"""WTF"""
if error:
logger.exception("Failed to obtain updates from Lutris.net: %s", error)
else:
component_updaters, runtime_updater = result
if component_updaters:
self.install_runtime_component_updates(component_updaters, runtime_updater)
else:
logger.debug("Runtime up to date")
AsyncCall(create_runtime_updater, create_runtime_updater_cb)

View File

@ -242,7 +242,9 @@ class RuntimeUpdater:
class RuntimeComponentUpdater(ComponentUpdater):
"""A base class for component updates that use the timestamp from a runtime-info dict
to decide when an update is required."""
to decide when an update is required.
(PS. You are not expected to understand what this docstring means)
"""
def __init__(self, remote_runtime_info: Dict[str, Any]) -> None:
self.remote_runtime_info = remote_runtime_info

View File

@ -11,7 +11,6 @@ from lutris.util.steam.config import get_steamapps_dirs
GE_PROTON_LATEST = _("GE-Proton (Latest)")
def is_proton_path(wine_path):
return "Proton" in wine_path and "lutris" not in wine_path