Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cli/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,20 @@ func cacheAPI(name string, api *API) {
}

Cache.Set(name+".expires", time.Now().Add(24*time.Hour))
Cache.WriteConfig()
if err := Cache.WriteConfig(); err != nil {
// Without the persisted expiry, LoadCachedAPI treats the cache as
// missing and every subsequent invocation re-syncs the spec.
// Surface the reason on stderr instead of silently degrading.
LogError("Could not persist API cache expiry (next runs will re-sync): %s", err)
}

b, err := cbor.Marshal(api)
if err != nil {
LogError("Could not marshal API cache %s", err)
}
filename := filepath.Join(getCacheDir(), name+".cbor")
if err := os.WriteFile(filename, b, 0o600); err != nil {
LogError("Could not write API cache %s", err)
LogError("Could not write API cache %s (next runs will re-sync): %s", filename, err)
}
}

Expand Down
Loading