From 7a4f69721ce972b1c8792dfeed9d252cf33b605f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 12 Apr 2023 16:05:01 -0700 Subject: [PATCH] fix: storage: Remove temp fetching files after failed fetch --- storage/paths/remote.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/paths/remote.go b/storage/paths/remote.go index 852936153bc..06bd39bf16e 100644 --- a/storage/paths/remote.go +++ b/storage/paths/remote.go @@ -236,6 +236,10 @@ func (r *Remote) acquireFromRemote(ctx context.Context, s abi.SectorID, fileType err = r.fetchThrottled(ctx, url, tempDest) if err != nil { merr = multierror.Append(merr, xerrors.Errorf("fetch error %s (storage %s) -> %s: %w", url, info.ID, tempDest, err)) + // fetching failed, remove temp file + if rerr := os.RemoveAll(tempDest); rerr != nil { + merr = multierror.Append(merr, xerrors.Errorf("removing temp dest (post-err cleanup): %w", rerr)) + } continue }