mox/moxio/syncdir.go
Mechiel Lukkien 5c33640aea
consistently use log.Check for logging errors that "should not happen", don't influence application flow
sooner or later, someone will notice one of these messages, which will lead us
to a bug.
2023-02-16 13:22:00 +01:00

18 lines
324 B
Go

package moxio
import (
"fmt"
"os"
)
// SyncDir opens a directory and syncs its contents to disk.
func SyncDir(dir string) error {
d, err := os.Open(dir)
if err != nil {
return fmt.Errorf("open directory: %v", err)
}
err = d.Sync()
xerr := d.Close()
xlog.Check(xerr, "closing directory after sync")
return err
}