]> git.giacomolli.uk - onechat/blobdiff - journal.go
Replay a synthetic log through the core
[onechat] / journal.go
index 3c2a7ef52e4e24cbd476f0705e5771739312c470..a962011785fc4f665bfb5e67bb5403b8b5d037e5 100644 (file)
@@ -18,7 +18,8 @@ type journal struct {
        day  string
 }
 
-// Write appends line to the file of day and flushes it to the disk.
+// Write appends line to the file of day with one write to the operating system,
+// without a buffer. A crash of the process then loses nothing.
 func (j *journal) Write(day string, line []byte) error {
        if day != j.day {
                err := j.Close()
@@ -39,11 +40,6 @@ func (j *journal) Write(day string, line []byte) error {
                return fmt.Errorf("write line: %w", err)
        }
 
-       err = j.file.Sync()
-       if err != nil {
-               return fmt.Errorf("flush line: %w", err)
-       }
-
        return nil
 }