Documentation
¶
Index ¶
- func ApplyAction(action Action, keep models.FileInfo, dup models.FileInfo, backupDir string) error
- func ApplyKeepStrategy(group models.DuplicateGroup, strategy string) (keep models.FileInfo, toRemove []models.FileInfo)
- func BuildReport(allFiles []models.FileInfo, groups []models.DuplicateGroup, scanPath string) models.Report
- func CountHardLinks(files []models.FileInfo) int
- func DeleteFile(path string) error
- func ExportCSV(report models.Report, path string) error
- func ExportHTML(report models.Report, path string) error
- func ExportJSON(report models.Report, path string) error
- func FindDuplicates(files []models.FileInfo, workers int) []models.DuplicateGroup
- func FormatSize(bytes int64) string
- func GroupByHash(annotated []AnnotatedFile) map[string][]models.FileInfo
- func GroupBySize(files []models.FileInfo) map[int64][]models.FileInfo
- func HashBlake3(path string) (string, error)
- func HashSHA256(path string) (string, error)
- func ImportJSON(path string) (models.Report, error)
- func MoveToBackup(dup, backupDir string) error
- func PlatformName() string
- func ReplaceWithHardLink(keep, dup string) error
- func ReplaceWithSoftLink(keep, dup string) error
- func Scan(cfg ScanConfig) ([]models.FileInfo, error)
- func SortGroupsByCount(groups []models.DuplicateGroup)
- func SortGroupsByPath(groups []models.DuplicateGroup)
- func SortGroupsBySize(groups []models.DuplicateGroup)
- type Action
- type AnnotatedFile
- type HashResult
- type ScanConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyAction ¶
ApplyAction performs the given action on a duplicate file.
func ApplyKeepStrategy ¶
func ApplyKeepStrategy(group models.DuplicateGroup, strategy string) (keep models.FileInfo, toRemove []models.FileInfo)
ApplyKeepStrategy selects which file to keep and which to remove.
func BuildReport ¶
func BuildReport(allFiles []models.FileInfo, groups []models.DuplicateGroup, scanPath string) models.Report
BuildReport creates a Report from the scan results.
func CountHardLinks ¶
CountHardLinks returns the number of files that are already hard-linked.
func ExportHTML ¶
ExportHTML writes a Report to a styled HTML file.
func ExportJSON ¶
ExportJSON writes a Report to a JSON file.
func FindDuplicates ¶
func FindDuplicates(files []models.FileInfo, workers int) []models.DuplicateGroup
FindDuplicates runs the full two-stage dedup pipeline: size grouping → Blake3 → SHA256 verification → duplicate groups.
func FormatSize ¶
FormatSize returns a human-readable file size string.
func GroupByHash ¶
func GroupByHash(annotated []AnnotatedFile) map[string][]models.FileInfo
GroupByHash groups annotated files by their hash, returning only groups with 2+ files.
func GroupBySize ¶
GroupBySize groups files by their size, returning only groups with 2+ files.
func HashBlake3 ¶
HashBlake3 computes the Blake3 hash of a file.
func HashSHA256 ¶
HashSHA256 computes the SHA256 hash of a file.
func ImportJSON ¶
ImportJSON reads a Report from a JSON file.
func MoveToBackup ¶
MoveToBackup moves a duplicate file to a backup directory, preserving structure.
func PlatformName ¶
func PlatformName() string
PlatformName returns a human-readable name for the current OS/arch.
func ReplaceWithHardLink ¶
ReplaceWithHardLink replaces dup with a hard link to keep.
func ReplaceWithSoftLink ¶
ReplaceWithSoftLink replaces dup with a symbolic link to keep.
func Scan ¶
func Scan(cfg ScanConfig) ([]models.FileInfo, error)
Scan discovers files using filepath.WalkDir for better performance, applies filters, and returns a list of FileInfo.
func SortGroupsByCount ¶
func SortGroupsByCount(groups []models.DuplicateGroup)
SortGroupsByCount sorts groups by number of copies descending.
func SortGroupsByPath ¶
func SortGroupsByPath(groups []models.DuplicateGroup)
SortGroupsByPath sorts groups alphabetically by first file path.
func SortGroupsBySize ¶
func SortGroupsBySize(groups []models.DuplicateGroup)
SortGroupsBySize sorts groups by file size descending (default).
Types ¶
type AnnotatedFile ¶
AnnotatedFile pairs a models.FileInfo with a hash result.
func AnnotateFiles ¶
func AnnotateFiles(files []models.FileInfo, algorithm string, workers int) []AnnotatedFile
AnnotateFiles adds hashes to file infos concurrently.
type HashResult ¶
HashResult is a single file hash result.
func HashPipeline ¶
func HashPipeline(paths []string, algorithm string, workers int) []HashResult
HashPipeline hashes a list of files concurrently using the given algorithm. algorithm: "blake3" or "sha256"