diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-04-20 11:05:35 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-04-20 15:09:12 +0200 |
commit | 004b6943906471cff0d0232040d24cff6cb89e6b (patch) | |
tree | 75d2492a0553a283c16a26cb5df9a178c5baa5ec /cache/dynacache/dynacache.go | |
parent | da6112fc65346d0f4e12b52d0580258cf02716c9 (diff) | |
download | hugo-004b6943906471cff0d0232040d24cff6cb89e6b.tar.gz hugo-004b6943906471cff0d0232040d24cff6cb89e6b.zip |
Fix partial rebuilds for SCSS fetched with GetMatch and similar
Fixes #12395
Diffstat (limited to 'cache/dynacache/dynacache.go')
-rw-r--r-- | cache/dynacache/dynacache.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/cache/dynacache/dynacache.go b/cache/dynacache/dynacache.go index eab251e5d..e79de5a5b 100644 --- a/cache/dynacache/dynacache.go +++ b/cache/dynacache/dynacache.go @@ -140,16 +140,25 @@ func (c *Cache) DrainEvictedIdentities() []identity.Identity { } // ClearMatching clears all partition for which the predicate returns true. -func (c *Cache) ClearMatching(predicate func(k, v any) bool) { +func (c *Cache) ClearMatching(predicatePartition func(k string, p PartitionManager) bool, predicateValue func(k, v any) bool) { + if predicatePartition == nil { + predicatePartition = func(k string, p PartitionManager) bool { return true } + } + if predicateValue == nil { + panic("nil predicateValue") + } g := rungroup.Run[PartitionManager](context.Background(), rungroup.Config[PartitionManager]{ NumWorkers: len(c.partitions), Handle: func(ctx context.Context, partition PartitionManager) error { - partition.clearMatching(predicate) + partition.clearMatching(predicateValue) return nil }, }) - for _, p := range c.partitions { + for k, p := range c.partitions { + if !predicatePartition(k, p) { + continue + } g.Enqueue(p) } @@ -356,6 +365,7 @@ func GetOrCreatePartition[K comparable, V any](c *Cache, name string, opts Optio trace: c.opts.Log.Logger().WithLevel(logg.LevelTrace).WithField("partition", name), opts: opts, } + c.partitions[name] = partition return partition |