mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
lib/fs: Ignore directory fsync failures
This commit is contained in:
parent
2760d032ca
commit
5ec1490be0
@ -319,13 +319,18 @@ func (f fsFile) Stat() (FileInfo, error) {
|
|||||||
|
|
||||||
func (f fsFile) Sync() error {
|
func (f fsFile) Sync() error {
|
||||||
err := f.File.Sync()
|
err := f.File.Sync()
|
||||||
// On Windows, fsyncing a directory returns a "handle is invalid"
|
if err == nil || runtime.GOOS != "windows" {
|
||||||
// So we swallow that and let things go through in order not to have to add
|
|
||||||
// a separate way of syncing directories versus files.
|
|
||||||
if err != nil && (runtime.GOOS != "windows" || !strings.Contains(err.Error(), "handle is invalid")) {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// On Windows, fsyncing a directory returns a "handle is invalid" (localized so can't check for strings)
|
||||||
|
// So we swallow that and let things go through in order not to have to add
|
||||||
|
// a separate way of syncing directories versus files.
|
||||||
|
if stat, serr := f.Stat(); serr != nil {
|
||||||
|
return serr
|
||||||
|
} else if stat.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// fsFileInfo implements the fs.FileInfo interface on top of an os.FileInfo.
|
// fsFileInfo implements the fs.FileInfo interface on top of an os.FileInfo.
|
||||||
|
Loading…
Reference in New Issue
Block a user