mirror of
https://github.com/restic/restic.git
synced 2025-08-12 03:47:41 +00:00

committed by
Michael Eischer

parent
59a90943bb
commit
348e966daa
@@ -6,6 +6,7 @@ package local
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
||||
"github.com/restic/restic/internal/fs"
|
||||
@@ -19,7 +20,9 @@ func fsyncDir(dir string) error {
|
||||
}
|
||||
|
||||
err = d.Sync()
|
||||
if errors.Is(err, syscall.ENOTSUP) || errors.Is(err, syscall.ENOENT) || errors.Is(err, syscall.EINVAL) {
|
||||
if err != nil &&
|
||||
(errors.Is(err, syscall.ENOTSUP) || errors.Is(err, syscall.ENOENT) ||
|
||||
errors.Is(err, syscall.EINVAL) || isMacENOTTY(err)) {
|
||||
err = nil
|
||||
}
|
||||
|
||||
@@ -31,6 +34,15 @@ func fsyncDir(dir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// set file to readonly
|
||||
func setFileReadonly(f string, mode os.FileMode) error {
|
||||
return fs.Chmod(f, mode&^0222)
|
||||
|
Reference in New Issue
Block a user