Skip to content

Fix DiffPipeline.ApplyPatch: handle differs that do internal atomic replacement - #274

Merged
JusterZhu merged 1 commit into
masterfrom
fix/pipeline-applypatch
May 23, 2026
Merged

Fix DiffPipeline.ApplyPatch: handle differs that do internal atomic replacement#274
JusterZhu merged 1 commit into
masterfrom
fix/pipeline-applypatch

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

Summary

Fix DiffPipeline.ApplyPatch to correctly handle IBinaryDiffer implementations that perform atomic file replacement internally (e.g., BinaryHandler).

Bug

BinaryHandler.DirtyAsync already does: delete old file, copy temp to old, delete temp. After it returns, tempPath no longer exists. DiffPipeline.ApplyPatch then:

  1. Deletes old file (which was just restored)
  2. Tries File.Move(temp, old) — temp doesn't exist — FileNotFoundException

Fix

ApplyPatch now checks if tempPath still exists after DirtyAsync:

  • Exists: differ left tempPath intact — do atomic replacement
  • Does not exist: differ already handled it — old file is already correct

…eaves tempPath intact (BinaryHandler already handles it)
Copilot AI review requested due to automatic review settings May 23, 2026 08:34
@JusterZhu
JusterZhu merged commit 22726d4 into master May 23, 2026
1 check failed
@JusterZhu
JusterZhu deleted the fix/pipeline-applypatch branch May 23, 2026 08:34
@JusterZhu
JusterZhu removed the request for review from Copilot May 23, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant