Skip to content

Commit b61788f

Browse files
committed
backupdest: attempt to close all stores in MakeBackupDestinationStores cleanupFn
Epic: none Release note: none
1 parent 191e4a1 commit b61788f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pkg/backup/backupdest/incrementals.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,24 @@ func MakeBackupDestinationStores(
216216
mkStore cloud.ExternalStorageFromURIFactory,
217217
destinationDirs []string,
218218
) ([]cloud.ExternalStorage, func() error, error) {
219-
incStores := make([]cloud.ExternalStorage, len(destinationDirs))
219+
stores := make([]cloud.ExternalStorage, len(destinationDirs))
220220
for i := range destinationDirs {
221221
store, err := mkStore(ctx, destinationDirs[i], user)
222222
if err != nil {
223223
return nil, nil, errors.Wrapf(err, "failed to open backup storage location")
224224
}
225-
incStores[i] = store
225+
stores[i] = store
226226
}
227227

228-
return incStores, func() error {
229-
// Close all the incremental stores in the returned cleanup function.
230-
for _, store := range incStores {
228+
return stores, func() error {
229+
// Close all the stores in the returned cleanup function.
230+
var combinedErr error
231+
for _, store := range stores {
231232
if err := store.Close(); err != nil {
232-
return err
233+
combinedErr = errors.CombineErrors(combinedErr, err)
233234
}
234235
}
235-
return nil
236+
return combinedErr
236237
}, nil
237238
}
238239

0 commit comments

Comments
 (0)