Conversation
Agent-Logs-Url: https://github.com/GeneralLibrary/GeneralUpdate/sessions/9fa32913-d903-40d0-9d97-8e765829c812 Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
|
@copilot The description in the issue indicates that the update failed because the patch was repeatedly restored to the same file. Could you explain why you deleted the file in this way? |
Here is the full call chain to explain the deletion:
The fix adds |
|
@copilot As of now, will all the code changes introduce new issues or affect the execution logic of the original code? |
The changes are minimal and do not alter any existing execution logic:
if (File.Exists(_newfilePath))
{
File.SetAttributes(_newfilePath, FileAttributes.Normal);
File.Copy(_newfilePath, _oldfilePath, true); // ← unchanged
File.Delete(_newfilePath); // ← new line
}
No execution path for the normal (non-error) case changes; the only behavioral difference is that the temp file is now cleaned up. |
|
@copilot I'm just asking. Please don't modify the code yet. Why isn't there a check during the update to determine whether the hash value of each file has been differentially updated? |
The The The bug was entirely in the temp-file lifetime: the randomly-named temp file (e.g., Adding a hash-based pre-check in the Dirty phase would be an alternative, but it would require the patch package to carry a manifest of expected post-patch hashes (the current |
There was a problem hiding this comment.
Pull request overview
Fixes a differential-update failure mode caused by BinaryHandler.Dirty leaving behind randomly-named temporary “new file” artifacts in the application directory after patch application, and adds a regression test to prevent recurrence.
Changes:
- Delete the temporary patched output file after copying it back to the original path in
BinaryHandler.Dirty. - Add a regression test asserting
DifferentialCore.Dirtyleaves no extra files in the app directory after applying a patch.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/c#/GeneralUpdate.Differential/Binary/BinaryHandler.cs | Cleans up the temp “new file” after copy-back to prevent orphan artifacts. |
| src/c#/DifferentialTest/DifferentialCoreTests.cs | Adds regression coverage ensuring no temp files remain after a patch run. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Each patch application wrote the result to a randomly-named temp file (e.g.,
4nl40ro2.p13_app.exe), copied it back to the original path, but never deleted the temp file. On the next update run,GetAllFilespicked up these orphans alongside the already-updated originals, causing theold→newpatch to be re-applied to an already-new file — producing corrupt output or a runtime error.Changes
BinaryHandler.Dirty: AddFile.Delete(_newfilePath)after the copy-back, cleaning up the temp file immediately after its content is committed to the final path.DifferentialCoreTests: Add regression testDirty_WithPatchFiles_DoesNotLeaveTemporaryFilesasserting that the app directory contains exactly the expected files (no orphan temp files) after a patch run.