Repository navigation
fix(desktop-gpui): tell a same-size replacement from the saved copy on Windows - #4313
Open
richiemcilroy wants to merge 4 commits into
Open
richiemcilroy wants to merge 4 commits into
richiemcilroy wants to merge 4 commits into
Conversation
…n Windows The delete guard fingerprints the copy a rule saved by length, modified time and, on unix, inode. Windows had no file identity in it, and CopyFile keeps the source's modified time, so a same-length file put in the copy's place inside one timestamp tick passed the check. That is what made delete_is_refused_when_the_saved_copy_is_not_the_one_this_run_wrote flaky on the Windows runner. Add the volume serial and NTFS file index, read through a short-lived handle opened with std's full share mode so it never holds up the later delete.
|
Sandchest · Sandchest couldn't finish reviewing Details · earlier results on this pull request no longer apply to the latest commit. |
…identity can refuse the delete
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Member
Author
|
@greptileai review |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automations only delete local files after checking that the copy a rule saved is still the file it wrote. On Windows that check could not tell a same-size file put in its place from the real copy.
Cause
FileFingerprintholds length, modified time and, on unix only,(dev, ino). Windows had no file identity.CopyFilekeeps the source's modified time, so a different file of the same length swapped in inside one timestamp tick produced an identical fingerprint and the delete went ahead.This also explains why
delete_is_refused_when_the_saved_copy_is_not_the_one_this_run_wrotewas flaky on the Windows runner: it panicked withunwrap_err()onOkin theBuild GPUI Desktop (x86_64-pc-windows-msvc)job on #4252, which does not touch automations.Change
file_id: (volume serial, NTFS file index)to the Windows fingerprint, read withGetFileInformationByHandle.std::fs::File::open. Std opens with read, write and delete sharing, and the handle drops before the function returns, so it never blocks the later delete.windows-sysalready enablesWin32_Storage_FileSystem.Proof
The Windows GPUI job runs the full automation test suite, including the replacement, edit and unwritten cases.


Confidence Score: 5/5
The PR appears safe to merge.Summary
Adds Windows file identity to the saved-copy check so a same-size replacement cannot pass just by keeping the original modified time.
Reviews (2) · Last reviewed commit: "test(desktop-gpui): pin the replacement'..." · Reviewed by Greptile