summaryrefslogtreecommitdiff
path: root/cache
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-05-17 02:13:25 +0200
committerewy <ewy0@protonmail.com>2026-05-17 02:13:25 +0200
commit5cfc8bd701037a215c62789916cda283a018d3fd (patch)
treed29c1b65e69314917e15390ce43e8bba0ae2bc2d /cache
parenteb340173fe0508240da4bb03d37a5a2fa259c2fd (diff)
add priority to version and completion to reduce start times for those modes
Diffstat (limited to 'cache')
-rw-r--r--cache/cache.go12
-rw-r--r--cache/cache_test.go10
2 files changed, 6 insertions, 16 deletions
diff --git a/cache/cache.go b/cache/cache.go
index 2784e23..9f25af0 100644
--- a/cache/cache.go
+++ b/cache/cache.go
@@ -12,18 +12,13 @@ import (
"strings"
)
+// Cache is a wrapper for its entries. I guess it could be a plain type.
type Cache struct {
Entries []Entry
}
type cacheInit struct{}
-var Init model.Initializer = &cacheInit{}
-
-func (i *cacheInit) Init() error {
- return nil
-}
-
// Merge combines two caches and filters duplicate keys
func (c *Cache) Merge(other *Cache) *Cache {
switch {
@@ -46,11 +41,13 @@ func (c *Cache) Merge(other *Cache) *Cache {
return result
}
+// Entry is a cache entry containing a path and name
type Entry struct {
Path string
Label string
}
+// String returns the string representation of this cache entry
func (e Entry) String() string {
return e.Path + " # " + e.Label
}
@@ -104,6 +101,7 @@ func (c *Cache) Marshal() []byte {
return []byte(b.String())
}
+// String returns the string representation of the Cache
func (c *Cache) String() string {
return string(c.Marshal())
}
@@ -118,6 +116,8 @@ func New(st *model.State) *Cache {
return c
}
+// MergeAndSave creates a cache from a state, combines it with
+// a potential saved context file, and writes it to disk
func MergeAndSave(in *model.State) error {
root := "/"
f := os.DirFS(root)
diff --git a/cache/cache_test.go b/cache/cache_test.go
index 204f670..7746be4 100644
--- a/cache/cache_test.go
+++ b/cache/cache_test.go
@@ -207,16 +207,6 @@ func TestMergeNilNormal(t *testing.T) {
_ = e.Merge(c)
}
-func TestCacheInit_Init(t *testing.T) {
- d := t.TempDir()
- paths.SetAll(d)
- defer paths.Reset()
- c := &cacheInit{}
- err := c.Init()
- assert.NoError(t, err)
- assert.Contains(t, paths.ContextsFile.String(), d)
-}
-
func TestInsert(t *testing.T) {
d := t.TempDir()
st := TState(TSource("source", "target"))