diff --git a/lib/db/instance.go b/lib/db/instance.go index 34b31e45..7e48dba1 100644 --- a/lib/db/instance.go +++ b/lib/db/instance.go @@ -48,9 +48,7 @@ func (db *instance) updateFiles(folder, device []byte, fs []protocol.FileInfo, m err = ef.Unmarshal(bs) } - // Local flags or the invalid bit might change without the version - // being bumped. The IsInvalid() method handles both. - if err == nil && ef.Version.Equal(f.Version) && ef.IsInvalid() == f.IsInvalid() { + if err == nil && unchanged(f, ef) { continue } @@ -563,3 +561,10 @@ type errorSuggestion struct { func (e errorSuggestion) Error() string { return fmt.Sprintf("%s (%s)", e.inner.Error(), e.suggestion) } + +// unchanged checks if two files are the same and thus don't need to be updated. +// Local flags or the invalid bit might change without the version +// being bumped. The IsInvalid() method handles both. +func unchanged(nf, ef FileIntf) bool { + return ef.FileVersion().Equal(nf.FileVersion()) && ef.IsInvalid() == nf.IsInvalid() +} diff --git a/lib/db/set.go b/lib/db/set.go index 2bb476c3..ed017f98 100644 --- a/lib/db/set.go +++ b/lib/db/set.go @@ -164,7 +164,7 @@ func (s *FileSet) Update(device protocol.DeviceID, fs []protocol.FileInfo) { folder := []byte(s.folder) for _, nf := range oldFs { ef, ok := s.db.getFileDirty(folder, device[:], []byte(osutil.NormalizedFilename(nf.Name))) - if ok && ef.Version.Equal(nf.Version) && ef.IsInvalid() == nf.IsInvalid() { + if ok && unchanged(nf, ef) { continue }