mox/moxio/syncdir.go

19 lines
324 B
Go
Raw Normal View History

2023-01-30 16:27:06 +03:00
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
2023-01-30 16:27:06 +03:00
}