mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
24 lines
597 B
Go
24 lines
597 B
Go
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)
|
|
}
|