all: Ignore Sync errors on directories (fixes #4432)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4449
This commit is contained in:
Audrius Butkevicius
2017-10-21 22:00:46 +00:00
committed by Jakob Borg
parent b1ade6d0c0
commit 622b614f31
3 changed files with 3 additions and 19 deletions

View File

@@ -317,22 +317,6 @@ func (f fsFile) Stat() (FileInfo, error) {
return fsFileInfo{info}, nil
}
func (f fsFile) Sync() error {
err := f.File.Sync()
if err == nil || runtime.GOOS != "windows" {
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 err
}
// fsFileInfo implements the fs.FileInfo interface on top of an os.FileInfo.
type fsFileInfo struct {
os.FileInfo