From 0ef5b8b280ce3f66f8d8e0a77a3c1746c28db298 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Wed, 27 Aug 2025 19:12:30 +0300 Subject: [PATCH] Fixed timer --- scripts/backup.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/backup.py b/scripts/backup.py index 39eaeb1..1267f57 100644 --- a/scripts/backup.py +++ b/scripts/backup.py @@ -128,7 +128,10 @@ def get_total_size(local_dir): for root, dirs, files in os.walk(local_dir): for f in files: fp = os.path.join(root, f) - total += os.path.getsize(fp) + try: + total += os.path.getsize(fp) + except (OSError, PermissionError) as e: + print(f"Error getting size of '{fp}': {e}") return total if __name__ == "__main__": @@ -156,10 +159,12 @@ if __name__ == "__main__": print(f"Files existed (skipped): {files_existed}") if mode == 'replace': print(f"Files replaced (trashed + uploaded): {files_replaced}") - print(f"Total file size: {total_size / (1024**3):.2f} GB") - print(f"Total time: {total_time:.2f} seconds") + print(f"Total file size: {total_size / (1024**2):.2f} MB") + print(f"Total time: {total_time / 60:.2f} minutes") if total_size > 0: - time_per_gb = total_time / (total_size / (1024**3)) - print(f"Time per GB: {time_per_gb:.2f} seconds/GB") + time_per_gb = (total_time / 60) / (total_size / (1024**3)) + print(f"Time per GB: {time_per_gb:.2f} minutes/GB") + megabits = total_size * 1024 * 128 # 128 is 1024/8 + print(f"Speed: {megabits / total_time}mbps") else: print("Time per GB: N/A (zero size)")