Skip to content

Commit c925450

Browse files
committed
fix(daemon): preserve curl-installer daemon as .bak instead of deleting
When `commandDaemonInstall` resolves to a system-managed binary (e.g. Homebrew, or a stale `/usr/local/bin/shelltime-daemon` on Linux), the cleanup branch previously deleted `~/.shelltime/bin/shelltime-daemon` outright. Combined with `install.bash` running `shelltime daemon reinstall` on upgrades, this caused the freshly-extracted daemon binary to be removed — and any subsequent `daemon install` would re-download it from GitHub releases. Rename the curl-installer copy to `shelltime-daemon.bak` instead. The existing `.bak` recovery branch at the top of `commandDaemonInstall` restores it on the next run, so once the user clears the stale system binary the daemon binary returns with no network fetch needed.
1 parent 784797f commit c925450

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

commands/daemon.install.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,20 @@ func commandDaemonInstall(c *cli.Context) error {
6161
color.Green.Printf("✅ Found daemon binary at: %s\n", daemonBinPath)
6262
}
6363

64-
// If we picked a system-managed binary but a stale curl-installer copy
65-
// still lives under ~/.shelltime/bin, remove it so future resolution
66-
// stays unambiguous.
64+
// If we picked a system-managed binary but a curl-installer copy still
65+
// lives under ~/.shelltime/bin, rename it to shelltime-daemon.bak rather
66+
// than delete it. Future resolution stays unambiguous AND the .bak
67+
// recovery branch above can restore it on the next `daemon install` —
68+
// no GitHub re-download when the user later clears the system binary.
6769
curlDaemonPath := model.GetCurlInstallerDaemonPath()
6870
if daemonBinPath != curlDaemonPath {
6971
if info, statErr := os.Stat(curlDaemonPath); statErr == nil && !info.IsDir() {
70-
if rmErr := os.Remove(curlDaemonPath); rmErr == nil {
71-
color.Yellow.Printf("🧹 Removed stale curl-installer daemon at %s\n", curlDaemonPath)
72+
preservedPath := curlDaemonPath + ".bak"
73+
_ = os.Remove(preservedPath)
74+
if rnErr := os.Rename(curlDaemonPath, preservedPath); rnErr == nil {
75+
color.Yellow.Printf("📦 Preserved curl-installer daemon as %s (auto-restores on next `daemon install`).\n", preservedPath)
7276
} else {
73-
color.Yellow.Printf("⚠️ Could not remove stale daemon at %s: %v\n", curlDaemonPath, rmErr)
77+
color.Yellow.Printf("⚠️ Could not preserve curl-installer daemon at %s: %v\n", curlDaemonPath, rnErr)
7478
}
7579
}
7680
}

0 commit comments

Comments
 (0)