1
0
Fork 0
mirror of synced 2024-10-01 17:57:00 +13:00

Add update manifest function and remove os.makedirs from proton_prefix_edit

This commit is contained in:
Dummerle 2021-11-09 21:31:25 +01:00
parent 1353f122c0
commit 4eae77ffff
No known key found for this signature in database
GPG key ID: AB68CC59CA39F2F1
2 changed files with 26 additions and 10 deletions

View file

@ -3,7 +3,7 @@ import platform
from typing import Tuple from typing import Tuple
from PyQt5.QtCore import QSettings from PyQt5.QtCore import QSettings
from PyQt5.QtWidgets import QWidget, QFileDialog, QMessageBox from PyQt5.QtWidgets import QWidget, QFileDialog
from legendary.core import LegendaryCore from legendary.core import LegendaryCore
from legendary.models.game import InstalledGame, Game from legendary.models.game import InstalledGame, Game
@ -169,15 +169,8 @@ class GameSettings(QWidget, Ui_GameSettings):
if not text: if not text:
text = os.path.expanduser("~/.proton") text = os.path.expanduser("~/.proton")
return True, text return True, text
if not os.path.exists(text): parent = os.path.dirname(text)
try: return os.path.exists(parent), text
os.makedirs(text)
except PermissionError:
QMessageBox.warning(self, "Warning", f"{self.tr('No permission to create folder')} {text}")
text = os.path.expanduser("~/.proton")
finally:
return True, text
return True, text
def proton_prefix_save(self, text: str): def proton_prefix_save(self, text: str):
self.core.lgd.config.set(self.game.app_name + ".env", "STEAM_COMPAT_DATA_PATH", text) self.core.lgd.config.set(self.game.app_name + ".env", "STEAM_COMPAT_DATA_PATH", text)

View file

@ -103,6 +103,22 @@ def uninstall(app_name: str, core: LegendaryCore, options=None):
core.lgd.save_config() core.lgd.save_config()
def update_manifest(app_name: str, core: LegendaryCore):
game = core.get_game(app_name)
logger.info('Reloading game manifest of ' + game.app_title)
new_manifest_data, base_urls = core.get_cdn_manifest(game)
# overwrite base urls in metadata with current ones to avoid using old/dead CDNs
game.base_urls = base_urls
# save base urls to game metadata
core.lgd.set_game_meta(game.app_name, game)
new_manifest = core.load_manifest(new_manifest_data)
logger.debug(f'Base urls: {base_urls}')
# save manifest with version name as well for testing/downgrading/etc.
core.lgd.save_manifest(game.app_name, new_manifest_data,
version=new_manifest.meta.build_version)
class VerifyThread(QThread): class VerifyThread(QThread):
status = pyqtSignal(tuple) status = pyqtSignal(tuple)
summary = pyqtSignal(int, int, str) summary = pyqtSignal(int, int, str)
@ -119,6 +135,13 @@ class VerifyThread(QThread):
logger.info(f'Loading installed manifest for "{self.app_name}"') logger.info(f'Loading installed manifest for "{self.app_name}"')
igame = self.core.get_installed_game(self.app_name) igame = self.core.get_installed_game(self.app_name)
manifest_data, _ = self.core.get_installed_manifest(self.app_name) manifest_data, _ = self.core.get_installed_manifest(self.app_name)
if not manifest_data:
update_manifest(self.app_name, self.core)
manifest_data, _ = self.core.get_installed_manifest(self.app_name)
if not manifest_data:
self.summary.emit(0, 0, self.app_name)
return
manifest = self.core.load_manifest(manifest_data) manifest = self.core.load_manifest(manifest_data)
files = sorted(manifest.file_manifest_list.elements, files = sorted(manifest.file_manifest_list.elements,