diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-04 00:39:14 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-04 00:39:14 +0900 |
| commit | bd0ef086b1fe2ecbbd1b1f401b8e546baa578952 (patch) | |
| tree | 4b5e7fca625c85b784fe2aa63ec8213963df8d71 /internal | |
| parent | 05202cf99481e4b005d766a1a5fdec5d2889396b (diff) | |
internal/pkg: enable cache access during store
This is still not ideal as it makes entry into Store sequential. This will be improved after more usage code is written.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/pkg/pkg.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go index e8547d16..1bc910ed 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) { |
