Fix huge download size shown for GOG games

This commit is contained in:
Mathieu Comandon 2023-10-16 03:39:09 -07:00
parent e943304e37
commit d60a5a4489
4 changed files with 19 additions and 8 deletions

View file

@ -23,7 +23,8 @@ class AccountsBox(BaseConfigBox):
main_radio_button = None
active_steam_account = settings.read_setting(STEAM_ACCOUNT_SETTING)
for account in get_steam_users():
steam_users = get_steam_users()
for account in steam_users:
radio_button = Gtk.RadioButton.new_with_label_from_widget(
main_radio_button,
account["PersonaName"]
@ -34,11 +35,11 @@ class AccountsBox(BaseConfigBox):
radio_button.show()
radio_button.set_active(active_steam_account == account["steamid64"])
radio_button.connect("toggled", self.on_steam_account_toggled, account["steamid64"])
vbox.pack_start(radio_button, False, False, 0)
vbox.pack_start(radio_button, True, True, 0)
if not main_radio_button:
main_radio_button = radio_button
else:
vbox.pack_start(Gtk.Label(_("No Steam account found")), False, False, 0)
if not steam_users:
vbox.pack_start(Gtk.Label(_("No Steam account found"), visible=True), True, True, 0)
def on_steam_account_toggled(self, radio_button, steamid64):
"""Handler for switching the active Steam account."""

View file

@ -237,6 +237,12 @@ class InstallerFile:
return self._file_meta["size"]
return 0
@property
def total_size(self):
if isinstance(self._file_meta, dict) and "total_size" in self._file_meta:
return self._file_meta["total_size"]
return 0
def is_ready(self, provider):
"""Is the file already present at the destination (if applicable)?"""
return provider not in ("user", "pga") or system.path_exists(self.dest_file)

View file

@ -27,13 +27,16 @@ class InstallerFileCollection:
self._get_service()
def _get_files_size(self):
if self.num_files > 0:
self.full_size = sum(f.size for f in self.files_list)
if len(self.files_list) > 0:
if self.files_list[0].total_size:
self.full_size = self.files_list[0].total_size
else:
self.full_size = sum(f.size for f in self.files_list)
def _get_service(self):
"""Try to get the service using the url of an InstallerFile"""
self.service = None
if self.num_files < 1:
if len(self.files_list) < 1:
return
url = self.files_list[0].url
url_parts = urlparse(url)

View file

@ -468,7 +468,8 @@ class GOGService(OnlineService):
"url": installer_file["url"],
"filename": installer_file["filename"],
"checksum_url": installer_file.get("checksum_url"),
"size": installer_file["total_size"]
"total_size": installer_file["total_size"],
"size": -1,
}))
if not file_id_provided:
raise UnavailableGameError(_("Unable to determine correct file to launch installer"))