You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Repeated failures fill the directory with stray files (e.g. aB12...).
After a panic from any other log.Fatal site in a sibling goroutine, this goroutine may also leave a temp file on disk because os.Exit skips deferred cleanup.
Suggested Fix
defer os.Remove(tempName) immediately after creating the temp file (the deferred remove is a no-op if the rename succeeds because the file no longer exists at tempName). Also avoid log.Fatalf from worker goroutines — return the error so all deferreds run.
Summary
In
File.Write, ifos.Rename(tempName, f.Path)returns an error,log.Fatalfis called and the temp file written next to the target is never cleaned up:Impact (Security/Reliability: Medium)
aB12...).log.Fatalsite in a sibling goroutine, this goroutine may also leave a temp file on disk becauseos.Exitskips deferred cleanup.Suggested Fix
defer os.Remove(tempName)immediately after creating the temp file (the deferred remove is a no-op if the rename succeeds because the file no longer exists attempName). Also avoidlog.Fatalffrom worker goroutines — return the error so all deferreds run.Files
file_handling.go:78-88(Write)