From 15a368f7e9f2ceb5b7605db06e704dcf998b710c Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Thu, 16 Jul 2026 22:47:11 -0600 Subject: [PATCH] perf(api): skip progress re-parse when the file is unchanged --- unshackle/core/api/download_manager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/unshackle/core/api/download_manager.py b/unshackle/core/api/download_manager.py index 3e7d3bdf..ef8590c8 100644 --- a/unshackle/core/api/download_manager.py +++ b/unshackle/core/api/download_manager.py @@ -905,6 +905,7 @@ class DownloadQueueManager: stdout_bytes = b"" stderr_bytes = b"" + last_progress_stat: Optional[tuple[int, int]] = None # (st_mtime_ns, st_size) of last parse try: while True: @@ -913,9 +914,12 @@ class DownloadQueueManager: stdout_bytes, stderr_bytes = communicate_task.result() break - # Check for progress updates + # Check for progress updates (skip re-parse when the file hasn't changed since last tick) try: - if os.path.exists(progress_path): + stat = os.stat(progress_path) + stat_key = (stat.st_mtime_ns, stat.st_size) + if stat_key != last_progress_stat: + last_progress_stat = stat_key with open(progress_path, "r", encoding="utf-8") as handle: progress_data = json.load(handle) if progress_data.get("phase") and progress_data["phase"] != job.phase: