lib/model: Fix test flakyness regression (ref #5592) (#5718)

This commit is contained in:
Simon Frei
2019-05-18 08:52:50 +02:00
committed by Jakob Borg
parent 1df8701c46
commit 5ffbb7668d
3 changed files with 48 additions and 39 deletions

View File

@@ -8,6 +8,7 @@ package model
import (
"io/ioutil"
"time"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/db"
@@ -121,3 +122,36 @@ func createTmpDir() string {
}
return tmpDir
}
type alwaysChangedKey struct {
fs fs.Filesystem
name string
}
// alwaysChanges is an ignore.ChangeDetector that always returns true on Changed()
type alwaysChanged struct {
seen map[alwaysChangedKey]struct{}
}
func newAlwaysChanged() *alwaysChanged {
return &alwaysChanged{
seen: make(map[alwaysChangedKey]struct{}),
}
}
func (c *alwaysChanged) Remember(fs fs.Filesystem, name string, _ time.Time) {
c.seen[alwaysChangedKey{fs, name}] = struct{}{}
}
func (c *alwaysChanged) Reset() {
c.seen = make(map[alwaysChangedKey]struct{})
}
func (c *alwaysChanged) Seen(fs fs.Filesystem, name string) bool {
_, ok := c.seen[alwaysChangedKey{fs, name}]
return ok
}
func (c *alwaysChanged) Changed() bool {
return true
}