Port fsync error handling from restic

This ignores several different combinations of errnos which are returned
if the storage destination is not able to fsync correctly.

See also https://github.com/restic/restic/pull/4021
This commit is contained in:
Michael Eischer
2022-11-11 22:37:02 +01:00
parent 2dd87ced0a
commit 408dcab92e
3 changed files with 45 additions and 5 deletions

19
repo/repo_unix.go Normal file
View File

@@ -0,0 +1,19 @@
//go:build !windows
// +build !windows
package repo
import (
"errors"
"runtime"
"syscall"
)
// The ExFAT driver on some versions of macOS can return ENOTTY,
// "inappropriate ioctl for device", for fsync.
//
// https://github.com/restic/restic/issues/4016
// https://github.com/realm/realm-core/issues/5789
func isMacENOTTY(err error) bool {
return runtime.GOOS == "darwin" && errors.Is(err, syscall.ENOTTY)
}