diff options
Diffstat (limited to 'files/index.go')
| -rw-r--r-- | files/index.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/files/index.go b/files/index.go deleted file mode 100644 index ea05dc4..0000000 --- a/files/index.go +++ /dev/null @@ -1,56 +0,0 @@ -package files - -import ( - "context" - "io/fs" - "path/filepath" - "time" - - "github.com/briandowns/spinner" - "golang.org/x/sync/errgroup" -) - -func IndexFlacs(ctx context.Context) error { - spin := spinner.New(spinner.CharSets[9], 100*time.Millisecond) - spin.Suffix = " Indexing flacs..." - - spin.Start() - - wg := new(errgroup.Group) - wg.SetLimit(100) - - if err := filepath.WalkDir(ctx.Value("path").(string), func(path string, info fs.DirEntry, err error) error { - select { - case <-ctx.Done(): - spin.FinalMSG = "Stopping...\n" - spin.Stop() - return nil - default: - if err != nil { - return err - } - if !info.IsDir() { - if filepath.Ext(path) == ".flac" { - wg.Go(func() error { - select { - case <-ctx.Done(): - return nil - default: - return ProcessFile(ctx, path, info) - } - }) - } - - } - return nil - } - - }); err != nil { - return err - } - - wg.Wait() - spin.FinalMSG = "Done indexing flacs" - spin.Stop() - return nil -} |
