Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin committed Aug 28, 2023
1 parent b46ca76 commit 67aabe5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions base/commands/project/project_list_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ func fetchTemplates() ([]Template, error) {
return templates, nil
}

func updateNextFetchTime(sa *store.StoreAccessor) error {
_, err := sa.WithLock(func(s *store.Store) (any, error) {
func updateNextFetchTime(s *store.Store) error {
_, err := func(s *store.Store) (any, error) {
v := []byte(strconv.FormatInt(time.Now().Add(cacheRefreshInterval).Unix(), 10))
return nil, s.SetEntry([]byte(nextFetchTimeKey), v)
})
}(s)
return err
}

Expand Down Expand Up @@ -194,11 +194,15 @@ func updateCache(sa *store.StoreAccessor, templates []Template) error {
return err
}
_, err = sa.WithLock(func(s *store.Store) (any, error) {
err = s.DeleteEntriesWithPrefix(templatesKey)
if err != nil {
return nil, err
}
err = s.SetEntry([]byte(templatesKey), b)
if err != nil {
return nil, err
}
if err = updateNextFetchTime(sa); err != nil {
if err = updateNextFetchTime(s); err != nil {
return nil, err
}
return nil, nil
Expand Down

0 comments on commit 67aabe5

Please sign in to comment.