State file is renamed without fsync ai:claude-sonnet-5-5 #53
Labels
No labels
nagonag
nagonag/ignore
bug
doc
duplicate
enhancement
help wanted
invalid
question
security
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
IUS/xr-invoiced#53
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Priority: minor
Found by a 100 Go Mistakes review (durability). Verified by reading the code.
Where:
internal/state/state.go:60-97(States.Save)Problem: The temp file is written, closed and renamed over
state.jsonwithouttmp.Sync()(and without syncing the directory). After a power loss the state file can be empty/truncated;Loadthen fails to unmarshal, the daemon starts with empty state and does a full rescan.Fix: Call
tmp.Sync()beforeClose().(co)authored by ai:claude-sonnet-5-5