mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 01:45:28 +00:00
[cli] Show average disk read speed during verification
This commit is contained in:
parent
d3ea2c6cfd
commit
9a3652086b
|
@ -1103,17 +1103,30 @@ class LegendaryCLI:
|
||||||
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)
|
total = len(file_list)
|
||||||
num = 0
|
total_size = sum(manifest.file_manifest_list.get_file_by_path(fm[0]).file_size
|
||||||
|
for fm in file_list)
|
||||||
|
num = processed = last_processed = 0
|
||||||
|
speed = 0.0
|
||||||
failed = []
|
failed = []
|
||||||
missing = []
|
missing = []
|
||||||
|
|
||||||
|
last_update = time.time()
|
||||||
|
|
||||||
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):
|
||||||
stdout.write(f'Verification progress: {num}/{total} ({num * 100 / total:.01f}%)\t\r')
|
processed += manifest.file_manifest_list.get_file_by_path(path).file_size
|
||||||
stdout.flush()
|
percentage = (processed / total_size) * 100.0
|
||||||
num += 1
|
num += 1
|
||||||
|
|
||||||
|
if (delta := ((current_time := time.time()) - last_update)) > 1 or not last_processed:
|
||||||
|
last_update = current_time
|
||||||
|
speed = (processed - last_processed) / 1024 / 1024 / delta
|
||||||
|
last_processed = processed
|
||||||
|
|
||||||
|
stdout.write(f'Verification progress: {num}/{total} ({percentage:.01f}%) [{speed:.1f} MiB/s]\t\r')
|
||||||
|
stdout.flush()
|
||||||
|
|
||||||
if result == VerifyResult.HASH_MATCH:
|
if result == VerifyResult.HASH_MATCH:
|
||||||
repair_file.append(f'{result_hash}:{path}')
|
repair_file.append(f'{result_hash}:{path}')
|
||||||
continue
|
continue
|
||||||
|
@ -1128,7 +1141,7 @@ class LegendaryCLI:
|
||||||
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: {num}/{total} ({num * 100 / total:.01f}%) [{speed:.1f} MiB/s]\t\n')
|
||||||
|
|
||||||
# always write repair file, even if all match
|
# always write repair file, even if all match
|
||||||
if repair_file:
|
if repair_file:
|
||||||
|
|
Loading…
Reference in a new issue