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