internal/pkg: enable cache access during store
All checks were successful
Test / Create distribution (push) Successful in 45s
Test / Sandbox (push) Successful in 2m37s
Test / Hakurei (push) Successful in 3m37s
Test / Hpkg (push) Successful in 4m32s
Test / Sandbox (race detector) (push) Successful in 4m57s
Test / Hakurei (race detector) (push) Successful in 5m53s
Test / ShareFS (push) Successful in 3m40s
Test / Flake checks (push) Successful in 1m47s
All checks were successful
Test / Create distribution (push) Successful in 45s
Test / Sandbox (push) Successful in 2m37s
Test / Hakurei (push) Successful in 3m37s
Test / Hpkg (push) Successful in 4m32s
Test / Sandbox (race detector) (push) Successful in 4m57s
Test / Hakurei (race detector) (push) Successful in 5m53s
Test / ShareFS (push) Successful in 3m40s
Test / Flake checks (push) Successful in 1m47s
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>
This commit is contained in:
@@ -144,7 +144,10 @@ type Cache struct {
|
|||||||
// Directory where all [Cache] related files are placed.
|
// Directory where all [Cache] related files are placed.
|
||||||
base *check.Absolute
|
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
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,8 +211,8 @@ func (c *Cache) Store(
|
|||||||
err error,
|
err error,
|
||||||
) {
|
) {
|
||||||
pathname = c.pathnameIdent(&id)
|
pathname = c.pathnameIdent(&id)
|
||||||
c.mu.Lock()
|
c.storeMu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.storeMu.Unlock()
|
||||||
|
|
||||||
_, err = os.Lstat(pathname.String())
|
_, err = os.Lstat(pathname.String())
|
||||||
if err == nil || !errors.Is(err, os.ErrNotExist) {
|
if err == nil || !errors.Is(err, os.ErrNotExist) {
|
||||||
|
|||||||
Reference in New Issue
Block a user