diff/walking: fix defer cleanup
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
This commit is contained in:
parent
055c801ede
commit
558fdc6808
@ -80,7 +80,7 @@ func (s *walkingDiff) Compare(ctx context.Context, lower, upper []mount.Mount, o
|
|||||||
|
|
||||||
var ocidesc ocispec.Descriptor
|
var ocidesc ocispec.Descriptor
|
||||||
if err := mount.WithTempMount(ctx, lower, func(lowerRoot string) error {
|
if err := mount.WithTempMount(ctx, lower, func(lowerRoot string) error {
|
||||||
return mount.WithTempMount(ctx, upper, func(upperRoot string) error {
|
return mount.WithTempMount(ctx, upper, func(upperRoot string) (retErr error) {
|
||||||
var newReference bool
|
var newReference bool
|
||||||
if config.Reference == "" {
|
if config.Reference == "" {
|
||||||
newReference = true
|
newReference = true
|
||||||
@ -96,7 +96,7 @@ func (s *walkingDiff) Compare(ctx context.Context, lower, upper []mount.Mount, o
|
|||||||
return errors.Wrap(err, "failed to open writer")
|
return errors.Wrap(err, "failed to open writer")
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if retErr != nil {
|
||||||
cw.Close()
|
cw.Close()
|
||||||
if newReference {
|
if newReference {
|
||||||
if abortErr := s.store.Abort(ctx, config.Reference); abortErr != nil {
|
if abortErr := s.store.Abort(ctx, config.Reference); abortErr != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user