internal/outcome: track state in TMPDIR
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m14s
Test / Hakurei (push) Successful in 3m7s
Test / Hpkg (push) Successful in 4m3s
Test / Sandbox (race detector) (push) Successful in 4m10s
Test / Hakurei (race detector) (push) Successful in 4m56s
Test / Flake checks (push) Successful in 1m30s
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m14s
Test / Hakurei (push) Successful in 3m7s
Test / Hpkg (push) Successful in 4m3s
Test / Sandbox (race detector) (push) Successful in 4m10s
Test / Hakurei (race detector) (push) Successful in 4m56s
Test / Flake checks (push) Successful in 1m30s
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>
This commit is contained in:
parent
f33aea9ff9
commit
7c3c3135d8
@ -322,7 +322,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
c.NewCommand("ps", "List active instances", func(args []string) error {
|
c.NewCommand("ps", "List active instances", func(args []string) error {
|
||||||
var sc hst.Paths
|
var sc hst.Paths
|
||||||
env.CopyPaths().Copy(&sc, new(outcome.Hsu).MustID(nil))
|
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
|
return errSuccess
|
||||||
}).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id")
|
}).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 {
|
return tryIdentifierEntries(msg, name, func() map[hst.ID]*hst.State {
|
||||||
var sc hst.Paths
|
var sc hst.Paths
|
||||||
env.CopyPaths().Copy(&sc, new(outcome.Hsu).MustID(nil))
|
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 {
|
if entries, err := store.Join(s); err != nil {
|
||||||
msg.GetLogger().Printf("cannot join store: %v", err) // not fatal
|
msg.GetLogger().Printf("cannot join store: %v", err) // not fatal
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -29,6 +29,9 @@ const (
|
|||||||
shimSetupTimeout = 5 * time.Second
|
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.
|
// main carries out outcome and terminates. main does not return.
|
||||||
func (k *outcome) main(msg message.Msg) {
|
func (k *outcome) main(msg message.Msg) {
|
||||||
if k.ctx == nil || k.sys == nil || k.state == nil {
|
if k.ctx == nil || k.sys == nil || k.state == nil {
|
||||||
@ -119,7 +122,7 @@ func (k *outcome) main(msg message.Msg) {
|
|||||||
|
|
||||||
switch processState {
|
switch processState {
|
||||||
case processStart:
|
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)
|
perrorFatal(err, "obtain store segment handle", processFinal)
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user