scanner

package
v0.1.1-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxSkippedFiles is the maximum number of skipped file paths to store
	// to prevent unbounded memory growth when scanning directories with millions of non-video files
	MaxSkippedFiles = 1000
)

Variables

View Source
var (
	ErrMaxFilesExceeded = errors.New("maximum file limit exceeded")
	ErrScanTimeout      = errors.New("scan operation timed out")
)

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Path      string    // Full absolute path
	Name      string    // Filename without path
	Extension string    // File extension (e.g., ".mp4")
	Size      int64     // File size in bytes
	ModTime   time.Time // Last modified time
	Dir       string    // Directory containing the file
}

FileInfo represents a discovered video file

type ScanResult

type ScanResult struct {
	Files        []FileInfo // Matched video files
	Skipped      []string   // Sample of skipped files (capped at MaxSkippedFiles)
	SkippedCount int        // Total count of skipped files
	Errors       []error    // Errors encountered during scan
	LimitReached bool       // Whether max file limit was reached
	TimedOut     bool       // Whether scan timed out
	TotalScanned int        // Total number of files scanned before limit/timeout
}

ScanResult contains the results of a directory scan

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner finds video files based on configuration

func NewScanner

func NewScanner(fs afero.Fs, cfg *config.MatchingConfig) *Scanner

NewScanner creates a new file scanner

func (*Scanner) Filter

func (s *Scanner) Filter(files []string) []FileInfo

Filter filters a list of files based on configuration

func (*Scanner) Scan

func (s *Scanner) Scan(rootPath string) (*ScanResult, error)

Scan recursively scans a directory for video files (no limits)

func (*Scanner) ScanSingle

func (s *Scanner) ScanSingle(path string) (*ScanResult, error)

ScanSingle scans a single file or directory (non-recursive)

func (*Scanner) ScanWithFilter

func (s *Scanner) ScanWithFilter(ctx context.Context, rootPath string, maxFiles int, filter string) (*ScanResult, error)

ScanWithFilter recursively scans a directory for video files with timeout, file count limits, and optional name filter maxFiles = 0 means no limit filter = "" means no filter; otherwise, only directories/files containing the filter string (case-insensitive) are processed

func (*Scanner) ScanWithLimits

func (s *Scanner) ScanWithLimits(ctx context.Context, rootPath string, maxFiles int) (*ScanResult, error)

ScanWithLimits recursively scans a directory for video files with timeout and file count limits maxFiles = 0 means no limit

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL