Don't call max() in every iteration

This commit is contained in:
Jeffrey Serio 2024-08-14 18:15:44 -05:00
parent 88cfe1aad3
commit 6d66ceb7e9

View File

@ -69,11 +69,12 @@ if __name__ == "__main__":
)
with TemporaryDirectory() as tmp_dir:
dir_sizes = []
max_dir_len = len(max(mirror_dirs, key=len))
for dir in mirror_dirs:
rsync_cmd = f"rsync -a -n --stats {args['-R']}/{dir}/ | grep '^Total file size' | tr -d ','"
output = subprocess.run(rsync_cmd, shell=True, capture_output=True)
logstr = (
dir.rjust(len(max(mirror_dirs, key=len)))
dir.rjust(max_dir_len)
+ " "
+ human_bytes(int(output.stdout.split()[3]))
)