The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix repair rollback config preservation
Justin D'Souza90fb15742a63
diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.goindex 2828b850..d67d0edc 100644--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go@@ -127,15 +127,7 @@ func (r *installRollback) Track(path string) {if _, ok := r.snapshots[path]; ok {return}- snapshot := fileSnapshot{}- if data, err := os.ReadFile(path); err == nil {- snapshot.Existed = true- snapshot.Data = data- if info, statErr := os.Stat(path); statErr == nil {- snapshot.Mode = info.Mode().Perm()- }- }- r.snapshots[path] = snapshot+ r.snapshots[path] = snapshotFile(path)r.files = append(r.files, path)}@@ -150,16 +142,7 @@ func (r *installRollback) Rollback(manifest Manifest) {restoreBackups(manifest.Backups)for i := len(r.files) - 1; i >= 0; i-- {path := r.files[i]- snapshot := r.snapshots[path]- if snapshot.Existed {- mode := snapshot.Mode- if mode == 0 {- mode = 0600- }- _ = os.WriteFile(path, snapshot.Data, mode)- continue- }- _ = os.Remove(path)+ restoreFile(path, r.snapshots[path])}}@@ -282,8 +265,14 @@ func Uninstall(opts UninstallOptions) error {}func Repair(opts InstallOptions) (InstallResult, error) {+ configPath := endpointconfig.ConfigPath(opts.UserMode)+ configSnapshot := snapshotFile(configPath)_ = Uninstall(UninstallOptions{UserMode: opts.UserMode, LogPath: opts.LogPath, KeepLogs: true, KeepConfig: true})- return Install(opts)+ result, err := Install(opts)+ if err != nil {+ restoreFile(configPath, configSnapshot)+ }+ return result, err}func GetStatus(userMode bool, logPath string) Status {@@ -449,6 +438,30 @@ func loadOrDefault(userMode bool, logPath string) endpointconfig.Config {return endpointconfig.Default(userMode, logPath)}+func snapshotFile(path string) fileSnapshot {+ snapshot := fileSnapshot{}+ if data, err := os.ReadFile(path); err == nil {+ snapshot.Existed = true+ snapshot.Data = data+ if info, statErr := os.Stat(path); statErr == nil {+ snapshot.Mode = info.Mode().Perm()+ }+ }+ return snapshot+}++func restoreFile(path string, snapshot fileSnapshot) {+ if !snapshot.Existed {+ _ = os.Remove(path)+ return+ }+ mode := snapshot.Mode+ if mode == 0 {+ mode = 0600+ }+ _ = os.WriteFile(path, snapshot.Data, mode)+}+func preflight(cfg endpointconfig.Config, startService bool) error {if err := endpointconfig.ValidateContentRetention(cfg.ContentRetention); err != nil {return err