mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: use static params when dynamic param metadata is missing (#17836)
Existing template versions do not have the metadata (modules + plan) in the db. So revert to using static parameter information from the original template import. This data will still be served over the websocket.
This commit is contained in:
+11
-2
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
// NewFromStore returns a file cache that will fetch files from the provided
|
||||
// database.
|
||||
func NewFromStore(store database.Store) Cache {
|
||||
func NewFromStore(store database.Store) *Cache {
|
||||
fetcher := func(ctx context.Context, fileID uuid.UUID) (fs.FS, error) {
|
||||
file, err := store.GetFileByID(ctx, fileID)
|
||||
if err != nil {
|
||||
@@ -27,7 +27,7 @@ func NewFromStore(store database.Store) Cache {
|
||||
return archivefs.FromTarReader(content), nil
|
||||
}
|
||||
|
||||
return Cache{
|
||||
return &Cache{
|
||||
lock: sync.Mutex{},
|
||||
data: make(map[uuid.UUID]*cacheEntry),
|
||||
fetcher: fetcher,
|
||||
@@ -112,3 +112,12 @@ func (c *Cache) Release(fileID uuid.UUID) {
|
||||
|
||||
delete(c.data, fileID)
|
||||
}
|
||||
|
||||
// Count returns the number of files currently in the cache.
|
||||
// Mainly used for unit testing assertions.
|
||||
func (c *Cache) Count() int {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
return len(c.data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user