lib/ignore: Refactor out result type (#9343)

This commit is contained in:
Jakob Borg
2024-01-13 18:58:23 +01:00
committed by GitHub
parent 36e08f8eee
commit e041877488
12 changed files with 155 additions and 87 deletions
+8 -4
View File
@@ -6,7 +6,11 @@
package ignore
import "time"
import (
"time"
"github.com/syncthing/syncthing/lib/ignore/ignoreresult"
)
type nower interface {
Now() time.Time
@@ -20,7 +24,7 @@ type cache struct {
}
type cacheEntry struct {
result Result
result ignoreresult.R
access int64 // Unix nanosecond count. Sufficient until the year 2262.
}
@@ -39,7 +43,7 @@ func (c *cache) clean(d time.Duration) {
}
}
func (c *cache) get(key string) (Result, bool) {
func (c *cache) get(key string) (ignoreresult.R, bool) {
entry, ok := c.entries[key]
if ok {
entry.access = clock.Now().UnixNano()
@@ -48,7 +52,7 @@ func (c *cache) get(key string) (Result, bool) {
return entry.result, ok
}
func (c *cache) set(key string, result Result) {
func (c *cache) set(key string, result ignoreresult.R) {
c.entries[key] = cacheEntry{result, time.Now().UnixNano()}
}