| 1 | package main |
| 2 | |
| 3 | import "reasonix/internal/control" |
| 4 | |
| 5 | // snapshotSettingsRebuildSource secures the outgoing runtime before migrating |
| 6 | // it. Callers hold runtimeRebuildMu and the tab's turn admission gate. |
| 7 | func (a *App) snapshotSettingsRebuildSource(tab *WorkspaceTab, old control.SessionAPI, path, setting string) error { |
| 8 | if _, _, exclusive := exclusiveSessionBinding(old); exclusive { |
| 9 | return a.snapshotTabForAction(tab, "rebuilding settings") |
| 10 | } |
| 11 | if err := a.ensureTabSessionLeaseForRebuild(tab, path, setting); err != nil { |
| 12 | return err |
| 13 | } |
| 14 | // A previous failed publication may have lost its lease. Reacquiring the |
| 15 | // OS lock must also restore write authority before the migration snapshot; |
| 16 | // otherwise every retry remains stale. |
| 17 | if err := bindTabWriteAuthority(tab, old); err != nil { |
| 18 | return err |
| 19 | } |
| 20 | return a.snapshotTabForAction(tab, "rebuilding settings") |
| 21 | } |
| 22 |