Skip to content

Commit

Permalink
fix: Abort lease on upload failure
Browse files Browse the repository at this point in the history
Closes vmware#3554.
  • Loading branch information
Xiol committed Sep 20, 2024
1 parent 3450f77 commit 36cac69
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ovf/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func (imp *Importer) Import(ctx context.Context, fpath string, opts Options) (*t

info, err := lease.Wait(ctx, spec.FileItem)
if err != nil {
_ = lease.Abort(ctx, nil)
return nil, err
}

Expand All @@ -169,6 +170,11 @@ func (imp *Importer) Import(ctx context.Context, fpath string, opts Options) (*t

for _, i := range info.Items {
if err := imp.Upload(ctx, lease, i); err != nil {
_ = lease.Abort(ctx, &types.LocalizedMethodFault{
Fault: &types.FileFault{
File: i.Path,
},
})
return nil, err
}
}
Expand Down

0 comments on commit 36cac69

Please sign in to comment.