Documentation
¶
Overview ¶
Package atomicfile writes a file so that a crash or a power cut can never leave a half-written one behind. The daemon's state and settings both live in a single JSON file that is rewritten in full, so a torn write there costs the whole torrent list.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadWithBackup ¶
ReadWithBackup reads path, falling back to "<path>.bak" when the main file is missing or parse reports it unusable. ok tells whether anything was read at all; fromBackup says the backup had to be used, which the caller may want to mention in its log.
func Write ¶
Write replaces path with data. The new content is flushed to the disk before the old file is replaced, so an interrupted write leaves either the previous file or the new one, never a truncated mix of the two. When keepBackup is set the file being replaced is kept as "<path>.bak", which ReadWithBackup falls back to.
Types ¶
This section is empty.