From f0ef10fa5063aa714a6c166e46de8844da6d055b Mon Sep 17 00:00:00 2001 From: Petu Eusebiu Date: Thu, 18 Nov 2021 14:52:32 +0200 Subject: [PATCH] sync: cleanup the orphaned private download dir on failure, closes 282 Signed-off-by: Petu Eusebiu --- pkg/extensions/sync/on_demand.go | 2 ++ pkg/extensions/sync/sync.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pkg/extensions/sync/on_demand.go b/pkg/extensions/sync/on_demand.go index edda06d5..e4ad0d1d 100644 --- a/pkg/extensions/sync/on_demand.go +++ b/pkg/extensions/sync/on_demand.go @@ -87,6 +87,8 @@ func OneImage(cfg Config, log log.Logger, return err } + defer os.RemoveAll(path.Join(imageStore.RootDir(), imageName, SyncBlobUploadDir, uuid.String())) + localTaggedRepo := fmt.Sprintf("%s:%s", localRepo, tag) localRef, err := layout.ParseReference(localTaggedRepo) diff --git a/pkg/extensions/sync/sync.go b/pkg/extensions/sync/sync.go index 6633a7ec..5ed08ca7 100644 --- a/pkg/extensions/sync/sync.go +++ b/pkg/extensions/sync/sync.go @@ -382,6 +382,8 @@ func syncRegistry(regCfg RegistryConfig, storeController storage.StoreController return err } + defer os.RemoveAll(path.Join(imageStore.RootDir(), imageName, SyncBlobUploadDir, uuid)) + upstreamTaggedRef := getTagFromRef(upstreamRef, log) localTaggedRepo := fmt.Sprintf("%s:%s", localRepo, upstreamTaggedRef.Tag())