Fix -max-tag filter.
[lightning.git] / slice.go
index d2073ad9c05f8900bc55dd8780e30bb6ca8cc699..a4899836be66510ac116aa65c90b168033898149 100644 (file)
--- a/slice.go
+++ b/slice.go
@@ -103,7 +103,7 @@ func (cmd *slicecmd) RunCommand(prog string, args []string, stdin io.Reader, std
 func Slice(tagsPerFile int, dstdir string, srcdirs []string) error {
        var infiles []string
        for _, srcdir := range srcdirs {
-               files, err := allGobFiles(srcdir)
+               files, err := allFiles(srcdir, matchGobFile)
                if err != nil {
                        return err
                }
@@ -136,19 +136,16 @@ func Slice(tagsPerFile int, dstdir string, srcdirs []string) error {
        throttle := throttle{Max: runtime.GOMAXPROCS(0)}
        for _, infile := range infiles {
                infile := infile
-               throttle.Acquire()
-               go func() {
-                       defer throttle.Release()
+               throttle.Go(func() error {
                        f, err := open(infile)
                        if err != nil {
-                               throttle.Report(err)
-                               return
+                               return err
                        }
                        defer f.Close()
                        dir, _ := filepath.Split(infile)
                        namespace := dirNamespace[dir]
                        log.Printf("reading %s (namespace %d)", infile, namespace)
-                       err = DecodeLibrary(f, strings.HasSuffix(infile, ".gz"), func(ent *LibraryEntry) error {
+                       return DecodeLibrary(f, strings.HasSuffix(infile, ".gz"), func(ent *LibraryEntry) error {
                                if err := throttle.Err(); err != nil {
                                        return err
                                }
@@ -241,8 +238,7 @@ func Slice(tagsPerFile int, dstdir string, srcdirs []string) error {
                                }
                                return nil
                        })
-                       throttle.Report(err)
-               }()
+               })
        }
        throttle.Wait()
        if throttle.Err() != nil {