forked from rosa/hakurei
Compare commits
2 Commits
159a45c027
...
ebdf9dcecc
| Author | SHA1 | Date | |
|---|---|---|---|
|
ebdf9dcecc
|
|||
|
8ea2a56d5b
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -260,6 +261,30 @@ func main() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.NewCommand(
|
||||||
|
"status",
|
||||||
|
"Display the status file of an artifact",
|
||||||
|
func(args []string) error {
|
||||||
|
if len(args) != 1 {
|
||||||
|
return errors.New("status requires 1 argument")
|
||||||
|
}
|
||||||
|
if p, ok := rosa.ResolveName(args[0]); !ok {
|
||||||
|
return fmt.Errorf("unknown artifact %q", args[0])
|
||||||
|
} else {
|
||||||
|
r, err := cache.OpenStatus(rosa.Std.Load(p))
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
return errors.New(args[0] + " was never cured")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = io.Copy(os.Stdout, r)
|
||||||
|
return errors.Join(err, r.Close())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
var (
|
var (
|
||||||
flagNet bool
|
flagNet bool
|
||||||
|
|||||||
@@ -1790,6 +1790,18 @@ func (pending *pendingArtifactDep) cure(c *Cache) {
|
|||||||
pending.errsMu.Unlock()
|
pending.errsMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OpenStatus attempts to open the status file associated to an [Artifact]. If
|
||||||
|
// err is nil, the caller must close the resulting reader.
|
||||||
|
func (c *Cache) OpenStatus(a Artifact) (r io.ReadSeekCloser, err error) {
|
||||||
|
c.identMu.RLock()
|
||||||
|
r, err = os.Open(c.base.Append(
|
||||||
|
dirStatus,
|
||||||
|
Encode(c.Ident(a).Value())).String(),
|
||||||
|
)
|
||||||
|
c.identMu.RUnlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Close cancels all pending cures and waits for them to clean up.
|
// Close cancels all pending cures and waits for them to clean up.
|
||||||
func (c *Cache) Close() {
|
func (c *Cache) Close() {
|
||||||
c.closeOnce.Do(func() {
|
c.closeOnce.Do(func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user