aboutsummaryrefslogtreecommitdiff
path: root/internal/scanner/scanner.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/scanner/scanner.go')
-rw-r--r--internal/scanner/scanner.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go
index d304605..2c766fe 100644
--- a/internal/scanner/scanner.go
+++ b/internal/scanner/scanner.go
@@ -5,10 +5,15 @@ import (
"path/filepath"
)
+// Scanner discovers image files from one or more filesystem roots
+//
+// Scanner is safe for concurrent use after construction,
+// provided Scan is not called concurrently
type Scanner struct {
config Config
}
+// New creates a Scanner using the supplied configuration.
func New(config Config) *Scanner {
clean := make([]string, len(config.Roots))
for i, root := range config.Roots {
@@ -21,9 +26,14 @@ func New(config Config) *Scanner {
}
}
-// Scan walks every configured root and returns the discovered files.
+// Scan recursively walks every configured root and returns the
+// discovered image files.
+//
+// Scan respects context cancellation.
+//
+// Returned files are deduplicated by absolute path.
//
-// The returned slice is not guaranteed to be sorted.
+// Results are not sorted.
func (s *Scanner) Scan(ctx context.Context) ([]File, error) {
files := make([]File, 0)
seen := make(map[string]struct{})