From 6aba50f5baad9d5d20fae11bac2e8fda30d9f982 Mon Sep 17 00:00:00 2001 From: alt-glitch Date: Sat, 11 Apr 2026 18:22:31 -0700 Subject: [PATCH] fix(file-sync): rollback _pushed_hashes on sync failure Snapshot _pushed_hashes alongside _synced_files before the try block so both are restored atomically on failure. Previously a mid-sync exception (e.g. host file deleted between upload and hash) would leave _pushed_hashes partially updated while _synced_files rolled back, causing sync_back() to make wrong change-detection decisions. --- tools/environments/file_sync.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/environments/file_sync.py b/tools/environments/file_sync.py index aa8e610bfc..2e7fce7697 100644 --- a/tools/environments/file_sync.py +++ b/tools/environments/file_sync.py @@ -161,6 +161,7 @@ class FileSyncManager: # Snapshot for rollback (only when there's work to do) prev_files = dict(self._synced_files) + prev_hashes = dict(self._pushed_hashes) if to_upload: logger.debug("file_sync: uploading %d file(s)", len(to_upload)) @@ -193,6 +194,7 @@ class FileSyncManager: except Exception as exc: self._synced_files = prev_files + self._pushed_hashes = prev_hashes self._last_sync_time = time.monotonic() logger.warning("file_sync: sync failed, rolled back state: %s", exc)