From dcd17c21a4f2095d4db86e3d429f68a34d523cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Majdand=C5=BEi=C4=87?= Date: Mon, 1 Jul 2024 17:43:14 +0200 Subject: [PATCH] Implement periodic file processing print --- util.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/util.go b/util.go index 530372e..48ed54a 100644 --- a/util.go +++ b/util.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "strings" + "time" ) func IsSymlink(path string) (bool, error) { @@ -65,6 +66,16 @@ func GetSyncFilesRecursively(input string, output chan string, status chan error defer close(output) defer close(status) + var filesProcessed int32 + progressTicker := time.NewTicker(200 * time.Millisecond) + defer progressTicker.Stop() + go func() { + for { + <-progressTicker.C + fmt.Printf("\rFiles processed: %d", filesProcessed) + } + }() + err := filepath.WalkDir(input, func(path string, file fs.DirEntry, err error) error { if err != nil { return err @@ -74,6 +85,7 @@ func GetSyncFilesRecursively(input string, output chan string, status chan error if !file.IsDir() && DirRegex.MatchString(path) { output <- path } + filesProcessed++ return nil })