feat: signed releases, release feed, notification (read-only)

This commit is contained in:
fsylvain committed 2026-10-01 15:01:53 +02:00
1 parent a49eec909c
commit 834493a4f5
49 files changed
+4191 -18

No files matched your search

@@ -0,0 +1,55 @@
package update
import (
domain "RenewCMS/internal/domain/update"
"encoding/json"
"os"
"path/filepath"
"sync"
)
const statusFilePermissions = 0o600
type JSONStatusStore struct {
path string
mu sync.Mutex
}
var _ domain.StatusStore = &JSONStatusStore{}
func NewJSONStatusStore(path string) *JSONStatusStore {
return &JSONStatusStore{path: path}
}
func (s *JSONStatusStore) Load() (domain.CheckResult, bool) {
s.mu.Lock()
defer s.mu.Unlock()
content, err := os.ReadFile(s.path)
if err != nil {
return domain.CheckResult{}, false
}
var result domain.CheckResult
if err := json.Unmarshal(content, &result); err != nil || result.CheckedAt.IsZero() {
return domain.CheckResult{}, false
}
return result, true
}
func (s *JSONStatusStore) Save(result domain.CheckResult) error {
s.mu.Lock()
defer s.mu.Unlock()
content, err := json.Marshal(result)
if err != nil {
return err
}
if err := os.MkdirAll(filepath.Dir(s.path), os.ModePerm); err != nil {
return err
}
temporary := s.path + ".tmp"
if err := os.WriteFile(temporary, content, statusFilePermissions); err != nil {
return err
}
return os.Rename(temporary, s.path)
}