fix(shell-sync): preserve synced guest changes on TUI interruption#5002
fix(shell-sync): preserve synced guest changes on TUI interruption#5002unsuman wants to merge 1 commit into
Conversation
13f4bfe to
ec82721
Compare
jandubois
left a comment
There was a problem hiding this comment.
The logic needs to be inverted to cover other failure cases too.
| remoteSource := fmt.Sprintf("%s:%s", inst.Name, destRsyncDir) | ||
| clean := filepath.Clean(hostCurrentDir) | ||
| dirForCleanup := shellescape.Quote(filepath.Join(*inst.Config.User.Home, clean)) | ||
| cleanupGuestWorkdir := true |
There was a problem hiding this comment.
I think the logic should be reverted: preserve the data, unless it has been confirmed it has been successfully copied or the user decided to discard. That automatically covers other failure scenarios that are not being considered in this PR.
| cleanupGuestWorkdir := true | |
| cleanupGuestWorkdir := false |
Possible other failures detected by Opus 4.7:
The defer still runs rm -rf on every other early-return path inside askUserForRsyncBack, several of which can fire after a successful guest session and would also silently destroy the user's work:
- cmd/limactl/shell.go:504 —
os.MkdirTempfailure on the host - cmd/limactl/shell.go:514 —
os.MkdirAllfailure on the host - cmd/limactl/shell.go:527 — non-Interrupt error from
uiutil.Select("failed to open TUI") - cmd/limactl/shell.go:549 —
rsyncDirectoryto the host temp dir fails (when user picked "View") - cmd/limactl/shell.go:559/569/589/600/607 — pager/diff pipe failures
- cmd/limactl/shell.go:460 — even the happy "Yes" path: if the final rsyncBack rsync itself fails (disk full, network blip), the defer still wipes the guest dir, losing the only remaining copy.
There was a problem hiding this comment.
Also, should we prompt the user during --sync if the target directory already exists?
If a user runs limactl shell --sync and Lima finds that the directory already exists in the guest, it should check for diff against the host. If there are any changes, Lima will prompt the user with this dialogue before starting the new session.
WARN[...] This directory already exists in the guest.
? ⚠️ Sync back changes to host? (added: 0, deleted: 0, modified: 1, metadata: 1) [Use arrows to move, type to filter]
> Yes
No (start fresh)
No (keep guest changes)
View the changed contents
Fixes lima-vm#4997 Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
ec82721 to
755ec52
Compare
Fixes #4997
When
SIGINTis sent during the exit dialogue oflimactl shell --sync, changes made during the synced session are lost. This PR fixes that.