From 68608a89adb94354e533682c4f2034929dadc264 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Tue, 29 Dec 2020 17:29:00 +0100 Subject: [PATCH] restic: add comment about StreamTrees shutdown --- internal/restic/tree_stream.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/restic/tree_stream.go b/internal/restic/tree_stream.go index 0c2a96810..871ba8998 100644 --- a/internal/restic/tree_stream.go +++ b/internal/restic/tree_stream.go @@ -147,7 +147,9 @@ func filterTrees(ctx context.Context, trees IDs, loaderChan chan<- trackedID, } // StreamTrees iteratively loads the given trees and their subtrees. The skip method -// is guaranteed to always be called from the same goroutine. +// is guaranteed to always be called from the same goroutine. To shutdown the started +// goroutines, either read all items from the channel or cancel the context. Then `Wait()` +// on the errgroup until all goroutines were stopped. func StreamTrees(ctx context.Context, wg *errgroup.Group, repo TreeLoader, trees IDs, skip func(tree ID) bool, p *progress.Counter) <-chan TreeItem { loaderChan := make(chan trackedID) loadedTreeChan := make(chan trackedTreeItem)