File tree 2 files changed +7
-174
lines changed 2 files changed +7
-174
lines changed Original file line number Diff line number Diff line change @@ -14,18 +14,10 @@ import (
14
14
"github.com/coder/coder/v2/coderd/util/lazy"
15
15
)
16
16
17
- func New (fetch fetcher ) * Cache {
18
- return & Cache {
19
- lock : sync.Mutex {},
20
- data : make (map [uuid.UUID ]* cacheEntry ),
21
- fetcher : fetch ,
22
- }
23
- }
24
-
25
17
// NewFromStore returns a file cache that will fetch files from the provided
26
18
// database.
27
- func NewFromStore (store database.Store ) * Cache {
28
- fetch := func (ctx context.Context , fileID uuid.UUID ) (fs.FS , error ) {
19
+ func NewFromStore (store database.Store ) Cache {
20
+ fetcher := func (ctx context.Context , fileID uuid.UUID ) (fs.FS , error ) {
29
21
file , err := store .GetFileByID (ctx , fileID )
30
22
if err != nil {
31
23
return nil , xerrors .Errorf ("failed to read file from database: %w" , err )
@@ -35,7 +27,11 @@ func NewFromStore(store database.Store) *Cache {
35
27
return archivefs .FromTarReader (content ), nil
36
28
}
37
29
38
- return New (fetch )
30
+ return Cache {
31
+ lock : sync.Mutex {},
32
+ data : make (map [uuid.UUID ]* cacheEntry ),
33
+ fetcher : fetcher ,
34
+ }
39
35
}
40
36
41
37
// Cache persists the files for template versions, and is used by dynamic
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments