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

@ -96,7 +96,7 @@ func (f *FolderConfiguration) CreateMarker() error {
}
if dir, err := fs.Open("."); err == nil {
if serr := dir.Sync(); err != nil {
l.Infof("fsync %q failed: %v", ".", serr)
l.Debugln("fsync %q failed: %v", ".", serr)
}
} else {
l.Infof("fsync %q failed: %v", ".", err)

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

View File

@ -1543,11 +1543,11 @@ func (f *sendReceiveFolder) dbUpdaterRoutine() {
delete(changedDirs, dir)
fd, err := f.fs.Open(dir)
if err != nil {
l.Infof("fsync %q failed: %v", dir, err)
l.Debugf("fsync %q failed: %v", dir, err)
continue
}
if err := fd.Sync(); err != nil {
l.Infof("fsync %q failed: %v", dir, err)
l.Debugf("fsync %q failed: %v", dir, err)
}
fd.Close()
}