feat: restart to apply update, privileged helper, rollback

This commit is contained in:
fsylvain committed 2026-10-01 21:36:40 +02:00
1 parent 70460e4170
commit 54e8fd5fed
63 files changed
+8635 -164

No files matched your search

@@ -0,0 +1,52 @@
package update
import (
domain "RenewCMS/internal/domain/update"
"encoding/json"
"os"
"sync"
)
type JSONResultStore struct {
path string
mu sync.Mutex
}
var _ domain.ResultStore = &JSONResultStore{}
func NewJSONResultStore(path string) *JSONResultStore {
return &JSONResultStore{path: path}
}
func (s *JSONResultStore) Read() (domain.Result, bool) {
s.mu.Lock()
defer s.mu.Unlock()
content, err := os.ReadFile(s.path)
if err != nil {
return domain.Result{}, false
}
return decodeResult(content)
}
func (s *JSONResultStore) Write(result domain.Result) error {
s.mu.Lock()
defer s.mu.Unlock()
return writeJSONAtomically(s.path, result, readableFilePermissions)
}
func (s *JSONResultStore) Delete() error {
s.mu.Lock()
defer s.mu.Unlock()
return removeIfPresent(s.path)
}
func decodeResult(content []byte) (domain.Result, bool) {
var result domain.Result
if err := json.Unmarshal(content, &result); err != nil || !result.IsKnown() {
return domain.Result{}, false
}
return result, true
}