Skip to content

Commit

Permalink
oci: walk: return error from Close if applicable
Browse files Browse the repository at this point in the history
Since we are reading blobs we should definitely be returning errors from
the lookup.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
  • Loading branch information
cyphar committed Mar 29, 2021
1 parent 1f954d4 commit 6353208
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions oci/casext/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var ErrSkipDescriptor = errors.New("[internal] do not recurse into descriptor")
// more than once. This is quite important for remote CAS implementations.
type WalkFunc func(descriptorPath DescriptorPath) error

func (ws *walkState) recurse(ctx context.Context, descriptorPath DescriptorPath) error {
func (ws *walkState) recurse(ctx context.Context, descriptorPath DescriptorPath) (Err error) {
log.WithFields(log.Fields{
"digest": descriptorPath.Descriptor().Digest,
}).Debugf("-> ws.recurse")
Expand Down Expand Up @@ -129,7 +129,13 @@ func (ws *walkState) recurse(ctx context.Context, descriptorPath DescriptorPath)
}
return err
}
defer blob.Close()
defer func() {
err := blob.Close()
if Err == nil {
log.Warnf("during recursion blob %v had error on Close: %v", descriptor.Digest, err)
Err = err
}
}()

// Recurse into children.
for _, child := range childDescriptors(blob.Data) {
Expand Down

0 comments on commit 6353208

Please sign in to comment.