diff options
| author | RanXom <saiyedshizain@gmail.com> | 2026-07-13 02:01:58 +0530 |
|---|---|---|
| committer | RanXom <saiyedshizain@gmail.com> | 2026-07-13 02:01:58 +0530 |
| commit | 9cd148b0fcc711edcac8c6becf8ea3cd31c871eb (patch) | |
| tree | 872fc37a63a90f23b2b7a3a5542b814ad75fa9a5 /internal/scanner/scanner.go | |
| parent | dc0bd0a705c21ce7fdccbb576534d74bc9f513cc (diff) | |
| download | galleryd-feat/scanner.tar.xz galleryd-feat/scanner.zip | |
doc(scanner): document public APIfeat/scanner
Diffstat (limited to 'internal/scanner/scanner.go')
| -rw-r--r-- | internal/scanner/scanner.go | 14 |
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{}) |