From 227f01e332f003c85e5fc507c3bd7b4c88e3d745 Mon Sep 17 00:00:00 2001 From: ldebruijn Date: Fri, 9 Aug 2024 16:21:52 +0200 Subject: [PATCH] feat(persisted-ops): Close both file and reader using defer --- internal/business/persistedoperations/gcp_storage_loader.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/business/persistedoperations/gcp_storage_loader.go b/internal/business/persistedoperations/gcp_storage_loader.go index 256613c..9a70705 100644 --- a/internal/business/persistedoperations/gcp_storage_loader.go +++ b/internal/business/persistedoperations/gcp_storage_loader.go @@ -64,12 +64,13 @@ func (g *GcpStorageLoader) Load(ctx context.Context) error { var errs []error for { attrs, err := it.Next() - numberOfFilesProcessed++ if errors.Is(err, iterator.Done) { break } if err != nil { + // if any error is returned, any subsequent call returns the same error + // so we break here errs = append(errs, err) break }