package tools import ( "io/fs" "os" "path/filepath" "strconv" "strings" "time" "velvettear/gosync/log" "velvettear/gosync/settings" ) var sourceFiles []string // unexported function(s) func getSourceFiles() []string { timestamp := time.Now() if settings.SourceIsRemote() { } else { source, _ := strings.CutSuffix(settings.Source, "/*") stats, error := os.Stat(source) if error != nil { log.Error("encountered an error getting the stats for the source", error.Error()) } if stats.IsDir() { log.Info("scanning source...", source) filepath.WalkDir(source, fillSourceFiles) } else { sourceFiles = append(sourceFiles, settings.Source) } } log.InfoTimed("found "+strconv.Itoa(len(sourceFiles))+" source files", timestamp.UnixMilli()) return sourceFiles } 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 }