diff options
Diffstat (limited to 'pkg/pkg.go')
| -rw-r--r-- | pkg/pkg.go | 34 |
1 files changed, 27 insertions, 7 deletions
@@ -206,7 +206,7 @@ func (t *TContext) prepareStatus(writeHeader bool) error { if t.status, t.statusErr = os.OpenFile( t.statusPath.String(), syscall.O_CREAT|syscall.O_EXCL|syscall.O_WRONLY, - 0400, + 0444, ); t.statusErr != nil { return t.statusErr } @@ -364,6 +364,9 @@ func (f *FContext) linkSubstitute(ids, substitutes string) (err error) { if err == nil { f.statusSPath = statusS } + if errors.Is(err, os.ErrExist) { + err = nil + } return } @@ -954,8 +957,9 @@ type ChecksumMismatchError struct { } func (e *ChecksumMismatchError) Error() string { - return "got " + Encode(e.Got) + - " instead of " + Encode(e.Want) + return "unexpected checksum\n" + + "\t got: " + Encode(e.Got) + "\n" + + "\twant: " + Encode(e.Want) } // LinknamePrefixError describes a malformed linkname to a [Checksum]. @@ -1521,7 +1525,7 @@ func (c *Cache) openFile( id := c.Ident(f) if c.msg.IsVerbose() { rn := reportName(f, id) - c.msg.Verbosef("curing %s%s%s in memory...", c.sgrIdent, rn, c.sgrRes) + c.msg.Verbosef("opening %s%s%s...", c.sgrIdent, rn, c.sgrRes) defer func() { if err == nil { c.msg.Verbosef("opened %s%s%s for reading", c.sgrIdent, rn, c.sgrRes) @@ -2053,6 +2057,9 @@ func WhenceString(whence int) string { } } +// isType returns whether v is of concrete type T. +func isType[T any](v any) bool { _, ok := v.(T); return ok } + // cure implements Cure without acquiring a read lock on abortMu. cure must not // be entered during Abort. func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) ( @@ -2170,7 +2177,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) ( } whence = WNew - if c.msg.IsVerbose() { + if c.msg.IsVerbose() && !isType[*Collect](a) { rn := reportName(a, id) c.msg.Verbosef("curing %s%s%s...", c.sgrIdent, rn, c.sgrRes) defer func() { @@ -2504,7 +2511,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) ( err = f.linkSubstitute(ids, substitutes) } if err != nil { - if c.msg.IsVerbose() { + if c.msg.IsVerbose() && !IsCollected(err) { c.msg.Verbosef( "cure %s%s%s: %s%v%s", c.sgrIdent, reportName(ca, id), c.sgrRes, @@ -2794,7 +2801,6 @@ func Open( dirSubstitute, dirIdentifier, dirChecksum, - dirStatus, dirFault, dirWork, } { @@ -2806,6 +2812,17 @@ func Open( } } + for _, name := range []string{ + dirStatus, + } { + if err := os.MkdirAll( + base.Append(name).String(), + 0711, + ); err != nil && !errors.Is(err, os.ErrExist) { + return nil, err + } + } + c := Cache{ parent: ctx, @@ -2919,6 +2936,9 @@ func Open( return &c, nil } +// Path returns the pathname of the directory holding [Cache] state. +func (c *Cache) Path() *check.Absolute { return c.base } + // Collected is returned by [Collect.Cure] to indicate a successful collection. type Collected struct{} |
