From 36cac699440b3b6371f5d628f3b658e5b8c0531a Mon Sep 17 00:00:00 2001 From: Dane Elwell Date: Fri, 20 Sep 2024 09:57:29 +0100 Subject: [PATCH] fix: Abort lease on upload failure Closes #3554. --- ovf/importer/importer.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ovf/importer/importer.go b/ovf/importer/importer.go index 55382f06c..07b24faf5 100644 --- a/ovf/importer/importer.go +++ b/ovf/importer/importer.go @@ -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 } @@ -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 } }