MCPcopy Create free account
hub / github.com/codehamr/codehamr / CleanupOld

Function CleanupOld

internal/update/update.go:232–243  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

230// fail that update spuriously; a genuinely orphaned partial just waits one
231// more launch.
232func CleanupOld(execPath string) {
233 _ = os.Remove(execPath + ".old")
234 // Interrupted downloads, plus the tool-output spill files tools.Execute
235 // writes when a result outgrows the context budget. A long unattended run
236 // can strand hundreds of megabytes of those, and a devcontainer's /tmp has
237 // no reaper of its own.
238 sweepOrphans(filepath.Join(filepath.Dir(execPath), ".codehamr-update-*"))
239 sweepOrphans(filepath.Join(os.TempDir(), "codehamr-out-*.txt"))
240}
241
242// sweepOrphans deletes files matching pattern that nothing has touched for
243// orphanSweepAge, so a live session's files are never pulled out from under it.
244func sweepOrphans(pattern string) {
245 matches, err := filepath.Glob(pattern)
246 if err != nil {

Callers 4

mainFunction · 0.92

Calls

no outgoing calls