diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-13 02:42:56 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-13 08:19:01 -0600 |
commit | f4d10a92abc46bf0156ff1b475304471c16405da (patch) | |
tree | 1c7dd77840d8b0851b58d4a1faf90ccd0da1805a /lib/btrfsutil/rebuilt_tree.go | |
parent | b35aa24d868637332c1ba804a12911445a5a664b (diff) |
Try to find misuses of textui.Progress
- Add a runtime-check to Progress to notice if we deadlocked or
forgot to call .Done().
- Add a runtime-check to Progress.Done() to panic if .Set() was never
called (instead of the old behavior of deadlocking).
- grep: Use `defer` when possible, to help remember to call .Done().
- grep: Always either call .Set() right away, or right before calling
.Done().
Diffstat (limited to 'lib/btrfsutil/rebuilt_tree.go')
-rw-r--r-- | lib/btrfsutil/rebuilt_tree.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/btrfsutil/rebuilt_tree.go b/lib/btrfsutil/rebuilt_tree.go index ffb2e5f..31a31be 100644 --- a/lib/btrfsutil/rebuilt_tree.go +++ b/lib/btrfsutil/rebuilt_tree.go @@ -259,11 +259,9 @@ func (tree *RebuiltTree) items(ctx context.Context, inc bool) containers.SortedM progressWriter.Set(stats) } } - if stats.Leafs.N > 0 { - stats.Leafs.N = stats.Leafs.D - progressWriter.Set(stats) - progressWriter.Done() - } + stats.Leafs.N = stats.Leafs.D + progressWriter.Set(stats) + progressWriter.Done() return index } |