package snapshot import ( "git.eeqj.de/sneak/vaultik/internal/config" "git.eeqj.de/sneak/vaultik/internal/database" "git.eeqj.de/sneak/vaultik/internal/storage" "github.com/spf13/afero" "go.uber.org/fx" ) // ScannerParams holds parameters for scanner creation type ScannerParams struct { EnableProgress bool Fs afero.Fs Exclude []string // Exclude patterns (combined global + snapshot-specific) SkipErrors bool // Skip file read errors (log loudly but continue) } // Module exports backup functionality as an fx module. // It provides a ScannerFactory that can create Scanner instances // with custom parameters while sharing common dependencies. var Module = fx.Module("backup", fx.Provide( provideScannerFactory, NewSnapshotManager, ), ) // ScannerFactory creates scanners with custom parameters type ScannerFactory func(params ScannerParams) *Scanner func provideScannerFactory(cfg *config.Config, repos *database.Repositories, storer storage.Storer) ScannerFactory { return func(params ScannerParams) *Scanner { // Use provided excludes, or fall back to global config excludes excludes := params.Exclude if len(excludes) == 0 { excludes = cfg.Exclude } return NewScanner(ScannerConfig{ FS: params.Fs, ChunkSize: cfg.ChunkSize.Int64(), Repositories: repos, Storage: storer, MaxBlobSize: cfg.BlobSizeLimit.Int64(), CompressionLevel: cfg.CompressionLevel, AgeRecipients: cfg.AgeRecipients, EnableProgress: params.EnableProgress, Exclude: excludes, SkipErrors: params.SkipErrors, }) } }