GameInfo: Detect repair_and_update
requirement
If a game was partially installed and it was imported through the import functionality, if `repair_and_update` is specified it will report `0` download size if there is no real update to be done. Fix it by detecting the need for an update explicitly. This will also force games that have failed verification to also update while repairing them, fixing the long-standing issue of repairing an older version of a game and then doing the update in a separate step.
This commit is contained in:
parent
c388f99c46
commit
785aaf648e
|
@ -81,14 +81,13 @@ class DownloadsTab(QWidget, Ui_DownloadsTab):
|
|||
if old_widget := self.update_widgets.get(app_name, False):
|
||||
old_widget.deleteLater()
|
||||
self.update_widgets.pop(app_name)
|
||||
igame: InstalledGame = self.core.get_installed_game(app_name)
|
||||
widget = UpdateWidget(self.core, igame, self)
|
||||
widget = UpdateWidget(self.core, app_name, self)
|
||||
self.update_layout.addWidget(widget)
|
||||
self.update_widgets[igame.app_name] = widget
|
||||
self.update_widgets[app_name] = widget
|
||||
widget.update_signal.connect(self.get_install_options)
|
||||
if QSettings().value("auto_update", False, bool):
|
||||
self.get_install_options(
|
||||
InstallOptionsModel(app_name=igame.app_name, update=True, silent=True)
|
||||
InstallOptionsModel(app_name=app_name, update=True, silent=True)
|
||||
)
|
||||
widget.update_button.setDisabled(True)
|
||||
self.update_text.setVisible(False)
|
||||
|
@ -101,14 +100,14 @@ class DownloadsTab(QWidget, Ui_DownloadsTab):
|
|||
self.queue_widget.update_queue(self.dl_queue)
|
||||
break
|
||||
|
||||
# game has available update
|
||||
if app_name in self.update_widgets.keys():
|
||||
self.remove_update(app_name)
|
||||
|
||||
# if game is updating
|
||||
if self.active_game and self.active_game.app_name == app_name:
|
||||
self.stop_download()
|
||||
|
||||
# game has available update
|
||||
if app_name in self.update_widgets.keys():
|
||||
self.remove_update(app_name)
|
||||
|
||||
def remove_update(self, app_name):
|
||||
if w := self.update_widgets.get(app_name):
|
||||
w.deleteLater()
|
||||
|
@ -228,6 +227,10 @@ class DownloadsTab(QWidget, Ui_DownloadsTab):
|
|||
def on_install_dialog_closed(self, download_item: InstallQueueItemModel):
|
||||
if download_item:
|
||||
self.install_game(download_item)
|
||||
# lk: In case the download in comming from game verification/repair
|
||||
if w := self.update_widgets.get(download_item.options.app_name):
|
||||
w.update_button.setDisabled(True)
|
||||
w.update_with_settings.setDisabled(True)
|
||||
self.signals.set_main_tab_index.emit(1)
|
||||
else:
|
||||
if w := self.update_widgets.get(download_item.options.app_name):
|
||||
|
@ -266,37 +269,37 @@ class DownloadsTab(QWidget, Ui_DownloadsTab):
|
|||
class UpdateWidget(QWidget):
|
||||
update_signal = pyqtSignal(InstallOptionsModel)
|
||||
|
||||
def __init__(self, core: LegendaryCore, igame: InstalledGame, parent):
|
||||
def __init__(self, core: LegendaryCore, app_name: str, parent):
|
||||
super(UpdateWidget, self).__init__(parent=parent)
|
||||
self.core = core
|
||||
self.game = igame
|
||||
self.game: Game = core.get_game(app_name)
|
||||
self.igame: InstalledGame = self.core.get_installed_game(app_name)
|
||||
|
||||
self.layout = QVBoxLayout()
|
||||
self.title = QLabel(self.game.title)
|
||||
self.layout.addWidget(self.title)
|
||||
layout = QVBoxLayout()
|
||||
self.title = QLabel(self.igame.title)
|
||||
layout.addWidget(self.title)
|
||||
|
||||
self.update_button = QPushButton(self.tr("Update Game"))
|
||||
self.update_button.clicked.connect(lambda: self.update_game(True))
|
||||
self.update_with_settings = QPushButton("Update with settings")
|
||||
self.update_with_settings.clicked.connect(lambda: self.update_game(False))
|
||||
self.layout.addWidget(self.update_button)
|
||||
self.layout.addWidget(self.update_with_settings)
|
||||
self.layout.addWidget(
|
||||
layout.addWidget(self.update_button)
|
||||
layout.addWidget(self.update_with_settings)
|
||||
layout.addWidget(
|
||||
QLabel(
|
||||
self.tr("Version: ")
|
||||
+ self.game.version
|
||||
+ " -> "
|
||||
+ self.core.get_asset(
|
||||
self.game.app_name, self.game.platform, False
|
||||
).build_version
|
||||
self.tr("Version: <b>")
|
||||
+ self.igame.version
|
||||
+ "</b> \u2B9E <b>"
|
||||
+ self.game.app_version(self.igame.platform)
|
||||
+ "</b>"
|
||||
)
|
||||
)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
self.setLayout(layout)
|
||||
|
||||
def update_game(self, auto: bool):
|
||||
self.update_button.setDisabled(True)
|
||||
self.update_with_settings.setDisabled(True)
|
||||
self.update_signal.emit(
|
||||
InstallOptionsModel(app_name=self.game.app_name, silent=auto)
|
||||
InstallOptionsModel(app_name=self.igame.app_name, silent=auto)
|
||||
) # True if settings
|
||||
|
|
|
@ -85,7 +85,7 @@ class GameInfo(QWidget, Ui_GameInfo):
|
|||
if self.args.offline:
|
||||
self.repair_button.setDisabled(True)
|
||||
else:
|
||||
self.repair_button.clicked.connect(self.repair)
|
||||
self.repair_button.clicked.connect(lambda: self.repair(self.igame))
|
||||
|
||||
self.install_button.clicked.connect(lambda: self.game_utils.launch_game(self.game.app_name))
|
||||
|
||||
|
@ -117,8 +117,10 @@ class GameInfo(QWidget, Ui_GameInfo):
|
|||
self.game_utils.update_list.emit(self.game.app_name)
|
||||
self.uninstalled.emit(self.game.app_name)
|
||||
|
||||
def repair(self):
|
||||
repair_file = os.path.join(self.core.lgd.get_tmp_path(), f"{self.game.app_name}.repair")
|
||||
@pyqtSlot(InstalledGame)
|
||||
def repair(self, igame: InstalledGame):
|
||||
game = self.core.get_game(igame.app_name)
|
||||
repair_file = os.path.join(self.core.lgd.get_tmp_path(), f"{igame.app_name}.repair")
|
||||
if not os.path.exists(repair_file):
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
|
@ -128,8 +130,9 @@ class GameInfo(QWidget, Ui_GameInfo):
|
|||
),
|
||||
)
|
||||
return
|
||||
update = igame.version != game.app_version(igame.platform)
|
||||
self.signals.install_game.emit(
|
||||
InstallOptionsModel(app_name=self.game.app_name, repair_mode=True, repair_and_update=True, update=True)
|
||||
InstallOptionsModel(app_name=self.game.app_name, repair_mode=True, repair_and_update=update, update=True)
|
||||
)
|
||||
|
||||
def verify(self):
|
||||
|
@ -188,7 +191,7 @@ class GameInfo(QWidget, Ui_GameInfo):
|
|||
QMessageBox.Yes,
|
||||
)
|
||||
if ans == QMessageBox.Yes:
|
||||
self.repair()
|
||||
self.repair(igame)
|
||||
self.verify_widget.setCurrentIndex(0)
|
||||
self.verify_threads.pop(app_name)
|
||||
self.move_button.setEnabled(True)
|
||||
|
|
|
@ -16,6 +16,10 @@ class LegendaryCore(LegendaryCoreReal):
|
|||
self.handler = LgndrCoreLogHandler()
|
||||
self.log.addHandler(self.handler)
|
||||
|
||||
# skip_sync defaults to false but since Rare is persistent, skip by default
|
||||
# def get_installed_game(self, app_name, skip_sync=True) -> InstalledGame:
|
||||
# return super(LegendaryCore, self).get_installed_game(app_name, skip_sync)
|
||||
|
||||
def prepare_download(self, game: Game, base_game: Game = None, base_path: str = '',
|
||||
status_q: Queue = None, max_shm: int = 0, max_workers: int = 0,
|
||||
force: bool = False, disable_patching: bool = False,
|
||||
|
|
|
@ -104,6 +104,7 @@ class VerifyWorker(QRunnable):
|
|||
# TODO: requires the client to be online. To do it this way, we need to
|
||||
# TODO: somehow detect the error and offer a dialog in which case `verify_games` is
|
||||
# TODO: re-run with `repair_mode` and `repair_online`
|
||||
# FIXME: This will crash in offline mode. Offline mode needs a re-thinking in general.
|
||||
result = self.cli.verify_game(
|
||||
args, print_command=False, repair_mode=True, repair_online=True)
|
||||
# success, failed, missing = self.cli.verify_game(args, print_command=False)
|
||||
|
|
Loading…
Reference in a new issue