Repository navigation
fix: sftp: saving an edit asks when the file changed after it was opened - #2049
Open
pwu2775-dev wants to merge 1 commit into
Open
pwu2775-dev wants to merge 1 commit into
pwu2775-dev wants to merge 1 commit into
Conversation
The editor path through the monitor's agent backend has, since it was written, compared the file the server now describes against the one the edit opened and asked before replacing it — "Before the bytes: a change in between then reads as a change at save, never as one silently overwritten". The SFTP path, which is the default one, had none: _edit fetched a copy, the editor held it for however long the user worked, and _saveBack queued the whole local file straight over the remote — so a change made in another terminal, by a deploy, or by a second device in those minutes was replaced without it ever being said. The mtime the listing gave _edit now travels to the save-back, which stats the remote once before writing and asks whether to overwrite when the two disagree (the same fileChangedOverwrite dialog the monitor path shows; reusing its string, no new l10n). Asked, not refused — the user may have seen the change and want their version anyway. A stat that cannot be had writes as before rather than blocking an edit it knows nothing about, and the sudo route runs through the same check.
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This branch has not been 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.
What this changes
The editor path through the monitor's agent backend has, since it was written, compared the file the server now describes against the one the edit opened and asked before replacing it — its own comment says "Before the bytes: a change in between then reads as a change at save, never as one silently overwritten". The SFTP path, which is the default one, had none:
_editfetched a copy, the editor held it for however long the user worked, and_saveBackqueued the whole local file straight over the remote — so a change made in another terminal, by a deploy, or by a second device in those minutes was replaced without it ever being said.The mtime the listing gave
_editnow travels to the save-back, which stats the remote once before writing and asks whether to overwrite when the two disagree — the samefileChangedOverwritedialog the monitor path shows (its string reused, no new l10n). Asked, not refused: the user may have seen the change and want their version anyway. A stat that cannot be had writes as before rather than blocking an edit it knows nothing about, and the sudo route runs through the same check.How it was tested
flutter analyze lib/view/page/storage/sftp.dartclean.sftp_file_backend_test(4) andsftp_replace_testpass. The behavioral change is the stat-and-ask in_saveBack, wired from the mtime the listing already carries (FileEntry.modified) — the same patternserver_file.dart'swriteIfUnchangedflow uses on the monitor side.Windows 11, Flutter 3.50.0. No model / ARB file changed, no
crates/change, no formatter run over untouched code.