internal/pkg: expose measured reader to extern status
Test / Create distribution (push) Successful in 59s
Test / Sandbox (push) Successful in 2m50s
Test / ShareFS (push) Successful in 3m55s
Test / Hakurei (push) Successful in 4m3s
Test / Sandbox (race detector) (push) Successful in 5m45s
Test / Hakurei (race detector) (push) Successful in 6m40s
Test / Flake checks (push) Successful in 1m12s
Test / Create distribution (push) Successful in 59s
Test / Sandbox (push) Successful in 2m50s
Test / ShareFS (push) Successful in 3m55s
Test / Hakurei (push) Successful in 4m3s
Test / Sandbox (race detector) (push) Successful in 5m45s
Test / Hakurei (race detector) (push) Successful in 6m40s
Test / Flake checks (push) Successful in 1m12s
This is always required by the implementation. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
+6
-6
@@ -699,13 +699,13 @@ type External interface {
|
|||||||
// Artifact returns the address of the [Checksum] of the cure outcome of
|
// Artifact returns the address of the [Checksum] of the cure outcome of
|
||||||
// an [Artifact] corresponding to id, or nil if this [Artifact] is not
|
// an [Artifact] corresponding to id, or nil if this [Artifact] is not
|
||||||
// available in the external cache.
|
// available in the external cache.
|
||||||
Artifact(id unique.Handle[ID]) (*Checksum, error)
|
Artifact(ctx context.Context, id unique.Handle[ID]) (*Checksum, error)
|
||||||
// Checksum returns an [Artifact] producing the specified checksum.
|
// Checksum returns an [Artifact] producing the specified checksum.
|
||||||
Checksum(checksum unique.Handle[Checksum]) Artifact
|
Checksum(checksum unique.Handle[Checksum]) Artifact
|
||||||
// Status returns [io.ReadCloser] of the status file of an [Artifact]
|
// Status returns [io.ReadCloser] of the status file of an [Artifact]
|
||||||
// corresponding to id, or nil if this [Artifact] is not available or a
|
// corresponding to id, or nil if this [Artifact] is not available or a
|
||||||
// status file is not present.
|
// status file is not present.
|
||||||
Status(id unique.Handle[ID]) (io.ReadCloser, error)
|
Status(r *RContext, id unique.Handle[ID]) (io.ReadCloser, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache is a support layer that implementations of [Artifact] can use to store
|
// Cache is a support layer that implementations of [Artifact] can use to store
|
||||||
@@ -1833,7 +1833,7 @@ func (r *RContext) NewMeasuredReader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// tryExtern attempts to obtain an [Artifact] outcome from extern.
|
// tryExtern attempts to obtain an [Artifact] outcome from extern.
|
||||||
func (c *Cache) tryExtern(id unique.Handle[ID]) (
|
func (c *Cache) tryExtern(ctx context.Context, id unique.Handle[ID]) (
|
||||||
unique.Handle[Checksum],
|
unique.Handle[Checksum],
|
||||||
io.ReadCloser,
|
io.ReadCloser,
|
||||||
error,
|
error,
|
||||||
@@ -1845,7 +1845,7 @@ func (c *Cache) tryExtern(id unique.Handle[ID]) (
|
|||||||
return zeroChecksum, nil, nil
|
return zeroChecksum, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := c.extern.Artifact(id)
|
v, err := c.extern.Artifact(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return zeroChecksum, nil, err
|
return zeroChecksum, nil, err
|
||||||
}
|
}
|
||||||
@@ -1862,7 +1862,7 @@ func (c *Cache) tryExtern(id unique.Handle[ID]) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
var status io.ReadCloser
|
var status io.ReadCloser
|
||||||
status, err = c.extern.Status(id)
|
status, err = c.extern.Status(&RContext{common{ctx, c}}, id)
|
||||||
return checksum, status, err
|
return checksum, status, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2205,7 +2205,7 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
|
|||||||
externChecksum unique.Handle[Checksum]
|
externChecksum unique.Handle[Checksum]
|
||||||
externStatus io.ReadCloser
|
externStatus io.ReadCloser
|
||||||
)
|
)
|
||||||
if externChecksum, externStatus, err = c.tryExtern(id); err != nil {
|
if externChecksum, externStatus, err = c.tryExtern(ctx, id); err != nil {
|
||||||
if c.msg.IsVerbose() {
|
if c.msg.IsVerbose() {
|
||||||
c.msg.Verbosef("extern %s: %v", reportName(ca, id), err)
|
c.msg.Verbosef("extern %s: %v", reportName(ca, id), err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ type stubExtern struct {
|
|||||||
status map[unique.Handle[pkg.ID]]string
|
status map[unique.Handle[pkg.ID]]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e stubExtern) Artifact(id unique.Handle[pkg.ID]) (*pkg.Checksum, error) {
|
func (e stubExtern) Artifact(_ context.Context, id unique.Handle[pkg.ID]) (*pkg.Checksum, error) {
|
||||||
if checksum, ok := e.artifact[id]; ok {
|
if checksum, ok := e.artifact[id]; ok {
|
||||||
return &checksum, nil
|
return &checksum, nil
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ func (e stubExtern) Checksum(checksum unique.Handle[pkg.Checksum]) pkg.Artifact
|
|||||||
return pkg.NewArchive(pkg.NewFile("", buf.Bytes()))
|
return pkg.NewArchive(pkg.NewFile("", buf.Bytes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e stubExtern) Status(id unique.Handle[pkg.ID]) (io.ReadCloser, error) {
|
func (e stubExtern) Status(_ *pkg.RContext, id unique.Handle[pkg.ID]) (io.ReadCloser, error) {
|
||||||
if status, ok := e.status[id]; ok {
|
if status, ok := e.status[id]; ok {
|
||||||
return io.NopCloser(strings.NewReader(status)), nil
|
return io.NopCloser(strings.NewReader(status)), nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user