Skip to content

Commit

Permalink
lib/model: Don't fail operation when fsync() fails (fixes syncthing#5704
Browse files Browse the repository at this point in the history
)
  • Loading branch information
calmh committed May 9, 2019
1 parent 62a6d61 commit 0f8066e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/model/sharedpullerstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,15 @@ func (s *sharedPullerState) finalClose() (bool, error) {
}

if s.fd != nil {
// This is our error if we weren't errored before. Otherwise we
// keep the earlier error.
if fsyncErr := s.fd.Sync(); fsyncErr != nil && s.err == nil {
s.err = fsyncErr
if err := s.fd.Sync(); err != nil {
// Sync() is nice if it works but not worth failing the
// operation over if it fails.
l.Debugf("fsync %q failed: %v", s.tempName, err)
}
if closeErr := s.fd.Close(); closeErr != nil && s.err == nil {
s.err = closeErr

if err := s.fd.Close(); err != nil && s.err == nil {
// This is our error as we weren't errored before.
s.err = err
}
s.fd = nil
}
Expand Down

0 comments on commit 0f8066e

Please sign in to comment.