More verifications at the same time
This commit is contained in:
parent
a42bf1c5c3
commit
76abc11d54
|
@ -46,6 +46,7 @@ class GameInfo(QWidget):
|
|||
game: Game
|
||||
update_list = pyqtSignal()
|
||||
verify_game = pyqtSignal(str)
|
||||
verify_threads = {}
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(GameInfo, self).__init__()
|
||||
|
@ -109,13 +110,20 @@ class GameInfo(QWidget):
|
|||
|
||||
def verify(self):
|
||||
self.game_actions.verify_widget.setCurrentIndex(1)
|
||||
self.verify_thread = VerifyThread(self.core, self.game.app_name)
|
||||
self.verify_thread.status.connect(lambda x: self.game_actions.verify_progress_bar.setValue(x[0] * 100 / x[1]))
|
||||
self.verify_thread.summary.connect(self.finish_verify)
|
||||
self.verify_thread.start()
|
||||
verify_thread = VerifyThread(self.core, self.game.app_name)
|
||||
verify_thread.status.connect(self.verify_satistics)
|
||||
verify_thread.summary.connect(self.finish_verify)
|
||||
verify_thread.start()
|
||||
self.game_actions.verify_progress_bar.setValue(0)
|
||||
self.verify_threads[self.game.app_name] = verify_thread
|
||||
|
||||
def verify_satistics(self, progress):
|
||||
# checked, max, app_name
|
||||
if progress[2] == self.game.app_name:
|
||||
self.game_actions.verify_progress_bar.setValue(progress[0] * 100 / progress[1])
|
||||
|
||||
def finish_verify(self, failed):
|
||||
failed, missing = failed
|
||||
failed, missing, app_name = failed
|
||||
if failed == 0 and missing == 0:
|
||||
QMessageBox.information(self, "Summary",
|
||||
"Game was verified successfully. No missing or corrupt files found")
|
||||
|
@ -126,6 +134,7 @@ class GameInfo(QWidget):
|
|||
if ans == QMessageBox.Yes:
|
||||
self.verify_game.emit(self.game.app_name)
|
||||
self.game_actions.verify_widget.setCurrentIndex(0)
|
||||
self.verify_threads.pop(app_name)
|
||||
|
||||
def update_game(self, app_name):
|
||||
self.game = self.core.get_game(app_name)
|
||||
|
@ -153,6 +162,13 @@ class GameInfo(QWidget):
|
|||
self.tr("Install size: ") + str(round(self.igame.install_size / (1024 ** 3), 2)) + " GB")
|
||||
self.install_path.setText(self.tr("Install path: ") + self.igame.install_path)
|
||||
|
||||
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(app_name):
|
||||
self.game_actions.verify_widget.setCurrentIndex(0)
|
||||
elif self.verify_threads.get(app_name):
|
||||
self.game_actions.verify_widget.setCurrentIndex(1)
|
||||
self.game_actions.verify_progress_bar.setValue(
|
||||
self.verify_threads[app_name].num / self.verify_threads[app_name].total * 100)
|
||||
|
||||
|
||||
class GameActions(QGroupBox):
|
||||
def __init__(self):
|
||||
|
|
|
@ -89,16 +89,16 @@ class VerifyThread(QThread):
|
|||
|
||||
# build list of hashes
|
||||
file_list = [(f.filename, f.sha_hash.hex()) for f in files]
|
||||
total = len(file_list)
|
||||
num = 0
|
||||
self.total = len(file_list)
|
||||
self.num = 0
|
||||
failed = []
|
||||
missing = []
|
||||
|
||||
logger.info(f'Verifying "{igame.title}" version "{manifest.meta.build_version}"')
|
||||
repair_file = []
|
||||
for result, path, result_hash in validate_files(igame.install_path, file_list):
|
||||
self.status.emit((num, total))
|
||||
num += 1
|
||||
self.status.emit((self.num, self.total, self.app_name))
|
||||
self.num += 1
|
||||
|
||||
if result == VerifyResult.HASH_MATCH:
|
||||
repair_file.append(f'{result_hash}:{path}')
|
||||
|
@ -114,7 +114,7 @@ class VerifyThread(QThread):
|
|||
logger.error(f'Other failure (see log), treating file as missing: "{path}"')
|
||||
missing.append(path)
|
||||
|
||||
stdout.write(f'Verification progress: {num}/{total} ({num * 100 / total:.01f}%)\t\n')
|
||||
stdout.write(f'Verification progress: {self.num}/{self.total} ({self.num * 100 / self.total:.01f}%)\t\n')
|
||||
|
||||
# always write repair file, even if all match
|
||||
if repair_file:
|
||||
|
@ -125,11 +125,11 @@ class VerifyThread(QThread):
|
|||
|
||||
if not missing and not failed:
|
||||
logger.info('Verification finished successfully.')
|
||||
self.summary.emit((0, 0))
|
||||
self.summary.emit((0, 0, self.app_name))
|
||||
|
||||
else:
|
||||
logger.error(f'Verification failed, {len(failed)} file(s) corrupted, {len(missing)} file(s) are missing.')
|
||||
self.summary.emit((len(failed), len(missing)))
|
||||
self.summary.emit((len(failed), len(missing), self.app_name))
|
||||
|
||||
|
||||
def import_game(core: LegendaryCore, app_name: str, path: str):
|
||||
|
|
Loading…
Reference in a new issue