Summary
If find-replace is killed (SIGKILL or hard process termination) mid-rewrite, any .find-replace-* temp file in the working tree survives because deferred cleanup does not run on os.Exit.
The walker on the next run will encounter these temp files, treat them as ordinary text files, and possibly rewrite/rename them — picking up garbage state.
Impact (Reliability: Low)
- Defensive: in normal operation, the deferred cleanup handles this. Only relevant after a hard kill, OOM, or pulled-cord scenario.
- Doesn't corrupt anything but leaves the tree dirty in a way the user has to clean up by hand.
Suggested Fix
In handleEntry, skip basenames matching .find-replace-*. Document that the prefix is reserved.
Optionally, on startup, scan for and remove orphan .find-replace-* temp files in the tree (with a --clean flag).
Files
find_replace.go:70-97 (handleEntry)
file_handling.go:105 (temp file pattern)
Summary
If
find-replaceis killed (SIGKILL or hard process termination) mid-rewrite, any.find-replace-*temp file in the working tree survives because deferred cleanup does not run onos.Exit.The walker on the next run will encounter these temp files, treat them as ordinary text files, and possibly rewrite/rename them — picking up garbage state.
Impact (Reliability: Low)
Suggested Fix
In
handleEntry, skip basenames matching.find-replace-*. Document that the prefix is reserved.Optionally, on startup, scan for and remove orphan
.find-replace-*temp files in the tree (with a--cleanflag).Files
find_replace.go:70-97(handleEntry)file_handling.go:105(temp file pattern)