dedupe/files/finder.go

56 lines
1.3 KiB
Go
Raw Normal View History

2023-08-11 13:34:54 +02:00
package files
import (
"io/fs"
"path/filepath"
"strconv"
"time"
"velvettear/dedupe/log"
"velvettear/dedupe/settings"
)
var sourceFiles []string
var comparisonFiles []string
// exported function(s)
func Scan() {
timestamp := time.Now()
log.Info("scanning source directory...", settings.SourceDirectory)
filepath.WalkDir(settings.SourceDirectory, fillSourceFiles)
log.InfoTimed("found "+strconv.Itoa(len(sourceFiles))+" source files", timestamp.UnixMilli())
timestamp = time.Now()
log.Info("scanning comparison directory...", settings.SourceDirectory)
filepath.WalkDir(settings.ComparisonDirectory, fillComparisonFiles)
log.InfoTimed("found "+strconv.Itoa(len(comparisonFiles))+" comparison files", timestamp.UnixMilli())
for _, sourceFile := range sourceFiles {
log.Debug("checking file", sourceFile)
sourceFileName := filepath.Base(sourceFile)
log.Debug("derp", sourceFileName)
}
}
// unexported function(s)
func fillSourceFiles(path string, dir fs.DirEntry, err error) error {
if err != nil {
return err
}
if dir.IsDir() {
return nil
}
sourceFiles = append(sourceFiles, path)
return nil
}
func fillComparisonFiles(path string, dir fs.DirEntry, err error) error {
if err != nil {
return err
}
if dir.IsDir() {
return nil
}
comparisonFiles = append(comparisonFiles, path)
return nil
}