2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 06:46:34 +00:00

Merge pull request #2439 from htrendev/ignore-sync-on-macos

Ignore not supported error on sync() when using local backend
This commit is contained in:
rawtaz 2020-08-22 01:38:49 +02:00 committed by GitHub
commit fa135f72bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -0,0 +1,12 @@
Enhancement: Ignore sync errors when operation not supported by local filesystem
The local backend has been modified to work with filesystems which doesn't support
the `sync` operation. This operation is normally used by restic to ensure that data
files are fully written to disk before continuing.
For these limited filesystems, saving a file in the backend would previously fail with
an "operation not supported" error. This error is now ignored, which means that e.g.
an SMB mount on macOS can now be used as storage location for a repository.
https://github.com/restic/restic/issues/2395
https://forum.restic.net/t/sync-errors-on-mac-over-smb/1859

View File

@ -5,6 +5,7 @@ import (
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"syscall"
"github.com/restic/restic/internal/errors" "github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic" "github.com/restic/restic/internal/restic"
@ -115,8 +116,13 @@ func (b *Local) Save(ctx context.Context, h restic.Handle, rd restic.RewindReade
} }
if err = f.Sync(); err != nil { if err = f.Sync(); err != nil {
_ = f.Close() pathErr, ok := err.(*os.PathError)
return errors.Wrap(err, "Sync") isNotSupported := ok && pathErr.Op == "sync" && pathErr.Err == syscall.ENOTSUP
// ignore error if filesystem does not support the sync operation
if !isNotSupported {
_ = f.Close()
return errors.Wrap(err, "Sync")
}
} }
err = f.Close() err = f.Close()