55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
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
|
|
}
|