diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go index e8547d1..1bc910e 100644 --- a/internal/pkg/pkg.go +++ b/internal/pkg/pkg.go @@ -144,7 +144,10 @@ type Cache struct { // Directory where all [Cache] related files are placed. base *check.Absolute - // Synchronises access to public methods. + // Protects the Store critical section. + storeMu sync.Mutex + + // Synchronises access to most public methods. mu sync.RWMutex } @@ -208,8 +211,8 @@ func (c *Cache) Store( err error, ) { pathname = c.pathnameIdent(&id) - c.mu.Lock() - defer c.mu.Unlock() + c.storeMu.Lock() + defer c.storeMu.Unlock() _, err = os.Lstat(pathname.String()) if err == nil || !errors.Is(err, os.ErrNotExist) {