Skip to content

Commit

Permalink
feat: simplify stats recording in filesystem reader
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed Oct 14, 2024
1 parent a14e1b3 commit 93c8343
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions walk/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func (f *FilesystemReader) process() error {
// Read populates the provided files array with as many files are available until the provided context is cancelled.
// You must ensure to pass a context with a timeout otherwise this will block until files is full.
func (f *FilesystemReader) Read(ctx context.Context, files []*File) (n int, err error) {
// ensure we record how many files we traversed
defer func() {
f.stats.Add(stats.Traversed, int32(n))
}()

idx := 0

LOOP:
Expand All @@ -102,9 +107,6 @@ LOOP:
// set the next file entry
files[idx] = file
idx++

// record that we traversed a file
f.stats.Add(stats.Traversed, 1)
}
}

Expand Down

0 comments on commit 93c8343

Please sign in to comment.