restic/internal/backend/local/local_unix.go

38 lines
530 B
Go
Raw Normal View History

2022-03-28 20:23:47 +00:00
//go:build !windows
// +build !windows
package local
import (
"errors"
"os"
"syscall"
2017-07-23 12:21:03 +00:00
"github.com/restic/restic/internal/fs"
)
// fsyncDir flushes changes to the directory dir.
func fsyncDir(dir string) error {
d, err := os.Open(dir)
if err != nil {
return err
}
err = d.Sync()
if errors.Is(err, syscall.ENOTSUP) {
err = nil
}
cerr := d.Close()
if err == nil {
err = cerr
}
return err
}
// set file to readonly
func setFileReadonly(f string, mode os.FileMode) error {
return fs.Chmod(f, mode&^0222)
}