diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-02 12:40:58 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-02 12:40:58 +0900 |
| commit | 7c3c3135d8b0eab767e58bd8ef0e7e04abee3ca2 (patch) | |
| tree | aa36cc12d1e36cfcc2956dff9336e0f33e8bce68 | |
| parent | f33aea9ff9c5eb678c6f1de59132aab69a59757e (diff) | |
internal/outcome: track state in TMPDIR
The SharePath is a more stable path than RunDirPath, since it is available all the time and should remain consistent. This also fits better into the intended use case of XDG_RUNTIME_DIR.
Closes #17.
Signed-off-by: Ophestra <cat@gensokyo.uk>
| -rw-r--r-- | cmd/hakurei/command.go | 2 | ||||
| -rw-r--r-- | cmd/hakurei/parse.go | 2 | ||||
| -rw-r--r-- | internal/outcome/process.go | 5 |
3 files changed, 6 insertions, 3 deletions
diff --git a/cmd/hakurei/command.go b/cmd/hakurei/command.go index e71ac16a..18bc9cef 100644 --- a/cmd/hakurei/command.go +++ b/cmd/hakurei/command.go @@ -322,7 +322,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr c.NewCommand("ps", "List active instances", func(args []string) error { var sc hst.Paths env.CopyPaths().Copy(&sc, new(outcome.Hsu).MustID(nil)) - printPs(os.Stdout, time.Now().UTC(), store.NewMulti(msg, sc.RunDirPath), flagShort, flagJSON) + printPs(os.Stdout, time.Now().UTC(), store.NewMulti(msg, sc.SharePath), flagShort, flagJSON) return errSuccess }).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id") } diff --git a/cmd/hakurei/parse.go b/cmd/hakurei/parse.go index 8aef8e98..51f2d5bd 100644 --- a/cmd/hakurei/parse.go +++ b/cmd/hakurei/parse.go @@ -85,7 +85,7 @@ func tryIdentifier(msg message.Msg, name string) (config *hst.Config, entry *hst return tryIdentifierEntries(msg, name, func() map[hst.ID]*hst.State { var sc hst.Paths env.CopyPaths().Copy(&sc, new(outcome.Hsu).MustID(nil)) - s := store.NewMulti(msg, sc.RunDirPath) + s := store.NewMulti(msg, sc.SharePath) if entries, err := store.Join(s); err != nil { msg.GetLogger().Printf("cannot join store: %v", err) // not fatal return nil diff --git a/internal/outcome/process.go b/internal/outcome/process.go index 1baa588c..78570d26 100644 --- a/internal/outcome/process.go +++ b/internal/outcome/process.go @@ -29,6 +29,9 @@ const ( shimSetupTimeout = 5 * time.Second ) +// NewStore returns the address of a new instance of [store.Store]. +func NewStore(sc *hst.Paths) *store.Store { return store.New(sc.SharePath.Append("state")) } + // main carries out outcome and terminates. main does not return. func (k *outcome) main(msg message.Msg) { if k.ctx == nil || k.sys == nil || k.state == nil { @@ -119,7 +122,7 @@ func (k *outcome) main(msg message.Msg) { switch processState { case processStart: - if h, err := store.New(k.state.sc.RunDirPath.Append("state")).Handle(k.state.identity.unwrap()); err != nil { + if h, err := NewStore(&k.state.sc).Handle(k.state.identity.unwrap()); err != nil { perrorFatal(err, "obtain store segment handle", processFinal) continue } else { |
