hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/internal/config/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/cache.go')
-rw-r--r--internal/config/cache.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/config/cache.go b/internal/config/cache.go
index 825af7f..aaaa97b 100644
--- a/internal/config/cache.go
+++ b/internal/config/cache.go
@@ -23,6 +23,18 @@ func LoadAPI() (*API, error) {
return &a, nil
}
+func SaveAPI(api *API) error {
+ if err := os.MkdirAll(Dir, 0o755); err != nil {
+ return err
+ }
+
+ data, err := json.MarshalIndent(api, "", " ")
+ if err != nil {
+ return err
+ }
+ return os.WriteFile(APIPath(), append(data, '\n'), 0o600)
+}
+
type ModState struct {
Compatible string `json:"compatible"`
Latest string `json:"latest"`