- Add internal/types package with type-safe wrappers for IDs, hashes, paths, and credentials (FileID, BlobID, ChunkHash, etc.) - Implement driver.Valuer and sql.Scanner for UUID-based types - Add `vaultik version` command showing version, commit, go version - Add `--verify` flag to restore command that checksums all restored files against expected chunk hashes with progress bar - Remove fetch.go (dead code, functionality in restore) - Clean up TODO.md, remove completed items - Update all database and snapshot code to use new custom types
54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
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,
|
|
})
|
|
}
|
|
}
|