mirror of
https://github.com/lutris/lutris
synced 2024-09-15 22:09:55 +00:00
Remove ability to cancel runtime updates
This commit is contained in:
parent
038fbb2d66
commit
23c413322f
|
@ -329,26 +329,18 @@ class LutrisInitDialog(Gtk.Dialog):
|
|||
self.progress_timeout = GLib.timeout_add(125, self.show_progress)
|
||||
self.show_all()
|
||||
|
||||
self.connect("response", self.on_response)
|
||||
self.connect("destroy", self.on_destroy)
|
||||
AsyncCall(self.run_init, self.init_cb)
|
||||
AsyncCall(self.runtime_updater.update_runtimes, self.init_cb)
|
||||
|
||||
def show_progress(self):
|
||||
self.progress.set_fraction(self.runtime_updater.percentage_completed())
|
||||
return True
|
||||
|
||||
def run_init(self):
|
||||
self.runtime_updater.update_runtimes()
|
||||
|
||||
def init_cb(self, _result, error: Exception):
|
||||
if error:
|
||||
ErrorDialog(error, parent=self)
|
||||
self.destroy()
|
||||
|
||||
def on_response(self, _widget, response):
|
||||
self.runtime_updater.cancel()
|
||||
self.destroy()
|
||||
|
||||
def on_destroy(self, window):
|
||||
GLib.source_remove(self.progress_timeout)
|
||||
return True
|
||||
|
|
|
@ -121,7 +121,7 @@ class Runtime:
|
|||
return
|
||||
return file_path
|
||||
|
||||
def get_runtime_components(self):
|
||||
def get_runtime_components(self) -> list:
|
||||
"""Fetch runtime components from the API"""
|
||||
request = http.Request(settings.RUNTIME_URL + "/" + self.name)
|
||||
try:
|
||||
|
@ -219,7 +219,6 @@ class Runtime:
|
|||
class RuntimeUpdater:
|
||||
"""Class handling the runtime updates"""
|
||||
|
||||
cancelled = False
|
||||
status_updater = None
|
||||
update_functions = []
|
||||
downloaders = {}
|
||||
|
@ -229,6 +228,7 @@ class RuntimeUpdater:
|
|||
self.pci_ids = pci_ids or []
|
||||
self.runtime_versions = {}
|
||||
self.add_update("runtime", self._update_runtime_components, hours=12)
|
||||
# self.add_update("runners", self._update_runners, hours=12)
|
||||
|
||||
def add_update(self, key: str, update_function, hours):
|
||||
"""__init__ calls this to register each update. This function
|
||||
|
@ -250,24 +250,12 @@ class RuntimeUpdater:
|
|||
return self.runtime_versions
|
||||
|
||||
def update_runtimes(self):
|
||||
"""Performs all the registered updates. If 'self.cancel()' is called,
|
||||
it will immediately stop."""
|
||||
"""Performs all the registered updates."""
|
||||
self.runtime_versions = download_runtime_versions(self.pci_ids)
|
||||
for key, func in self.update_functions:
|
||||
if self.cancelled:
|
||||
break
|
||||
func()
|
||||
update_cache.write_date_to_cache(key)
|
||||
|
||||
if self.cancelled:
|
||||
logger.info("Runtime update cancelled")
|
||||
logger.info("Startup complete")
|
||||
|
||||
def cancel(self):
|
||||
self.cancelled = True
|
||||
for downloader in self.downloaders.values():
|
||||
downloader.cancel()
|
||||
|
||||
def _update_runtime_components(self):
|
||||
"""Update runtime components"""
|
||||
components_to_update = self._populate_component_downloaders()
|
||||
|
@ -277,6 +265,10 @@ class RuntimeUpdater:
|
|||
if self.cancelled:
|
||||
return
|
||||
|
||||
# def _update_runners(self):
|
||||
# """Update installed runners (only works for Wine at the moment)"""
|
||||
# upstream_runners = self.runtime_versions.get("runners", {})
|
||||
|
||||
def percentage_completed(self) -> float:
|
||||
if not self.downloaders:
|
||||
return 0
|
||||
|
|
Loading…
Reference in a new issue