Skip to content

Commit

Permalink
client: refactor StatFile fallback for SolveRequest.Evaluate
Browse files Browse the repository at this point in the history
The StatFile fallback needs reworking to ensure that all refs in the
result are evaluated, not just the first one found.

Signed-off-by: Justin Chadwell <[email protected]>
  • Loading branch information
jedevc committed Oct 12, 2022
1 parent 5cb44cb commit fa28d89
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions frontend/gateway/grpcclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,30 +387,15 @@ func (c *grpcClient) Solve(ctx context.Context, creq client.SolveRequest) (res *
if c.caps.Supports(pb.CapGatewayEvaluateSolve) == nil {
req.Evaluate = creq.Evaluate
} else {
// If evaluate is not supported, fallback to running Stat(".") in order to
// trigger an evaluation of the result.
// If evaluate is not supported, fallback to running Stat(".") in
// order to trigger an evaluation of the result.
defer func() {
if res == nil {
return
}

var (
id string
ref client.Reference
)
ref, err = res.SingleRef()
if err != nil {
for refID := range res.Refs {
id = refID
break
}
} else {
id = ref.(*reference).id
}

_, err = c.client.StatFile(ctx, &pb.StatFileRequest{
Ref: id,
Path: ".",
err = res.EachRef(func(ref client.Reference) error {
_, err := ref.StatFile(ctx, client.StatRequest{Path: "."})
return err
})
}()
}
Expand Down

0 comments on commit fa28d89

Please sign in to comment.