CleanupOld removes the execPath+".old" left by a previous Apply. Run at the start of the next launch: on Windows the .old is locked for the prior process's lifetime, so unlink-at-Apply-time fails but unlink-at-next-launch wins. Failure is silent: a leftover .old wastes disk but never breaks the sess
(execPath string)
| 230 | // fail that update spuriously; a genuinely orphaned partial just waits one |
| 231 | // more launch. |
| 232 | func CleanupOld(execPath string) { |
| 233 | _ = os.Remove(execPath + ".old") |
| 234 | matches, err := filepath.Glob(filepath.Join(filepath.Dir(execPath), ".codehamr-update-*")) |
| 235 | if err != nil { |
| 236 | return |
| 237 | } |
| 238 | for _, m := range matches { |
| 239 | if info, err := os.Stat(m); err == nil && time.Since(info.ModTime()) > orphanSweepAge { |
| 240 | _ = os.Remove(m) |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | // orphanSweepAge is how old a .codehamr-update-* temp must be before the |
| 246 | // launch sweep treats it as orphaned rather than another instance's live |
no outgoing calls