mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: don't cache errors in file cache (#18555)
This commit is contained in:
23
coderd/files/cache_internal_test.go
Normal file
23
coderd/files/cache_internal_test.go
Normal file
@ -0,0 +1,23 @@
|
||||
package files
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
)
|
||||
|
||||
// LeakCache prevents entries from even being released to enable testing certain
|
||||
// behaviors.
|
||||
type LeakCache struct {
|
||||
*Cache
|
||||
}
|
||||
|
||||
func (c *LeakCache) Acquire(ctx context.Context, db database.Store, fileID uuid.UUID) (*CloseFS, error) {
|
||||
// We need to call prepare first to both 1. leak a reference and 2. prevent
|
||||
// the behavior of immediately closing on an error (as implemented in Acquire)
|
||||
// from freeing the file.
|
||||
c.prepare(db, fileID)
|
||||
return c.Cache.Acquire(ctx, db, fileID)
|
||||
}
|
Reference in New Issue
Block a user