feat: add Arch update helper and web UI

This commit is contained in:
2026-05-03 22:48:01 +02:00
parent cbe105a719
commit 653ff6d298
12 changed files with 1349 additions and 0 deletions

43
internal/state/state.go Normal file
View File

@@ -0,0 +1,43 @@
package state
import (
"encoding/json"
"errors"
"os"
"path/filepath"
"time"
)
type Store struct {
LastReminder time.Time `json:"last_reminder"`
LastUpdateCount int `json:"last_update_count"`
}
func Load(path string) (Store, error) {
data, err := os.ReadFile(path)
if errors.Is(err, os.ErrNotExist) {
return Store{}, nil
}
if err != nil {
return Store{}, err
}
var store Store
if err := json.Unmarshal(data, &store); err != nil {
return Store{}, err
}
return store, nil
}
func Save(path string, store Store) error {
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
return err
}
data, err := json.MarshalIndent(store, "", " ")
if err != nil {
return err
}
data = append(data, '\n')
return os.WriteFile(path, data, 0o644)
}