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:
Steven Masley
2025-05-16 11:47:59 -05:00
committed by GitHub
parent fb0e3d64db
commit f36fb67f57
14 changed files with 558 additions and 251 deletions
+11 -2
View File
@@ -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)
}