mirror of
https://github.com/coalaura/ffwebp.git
synced 2025-09-08 05:49:54 +00:00
cleanup
This commit is contained in:
@@ -199,6 +199,10 @@ func run(_ context.Context, cmd *cli.Command) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(inputs) == 1 {
|
||||||
|
return processOne(inputs[0], outputs[0], cmd, &common, nil)
|
||||||
|
}
|
||||||
|
|
||||||
threads := cmd.Int("threads")
|
threads := cmd.Int("threads")
|
||||||
|
|
||||||
if threads <= 0 {
|
if threads <= 0 {
|
||||||
@@ -207,6 +211,8 @@ func run(_ context.Context, cmd *cli.Command) error {
|
|||||||
|
|
||||||
threads = min(threads, len(inputs))
|
threads = min(threads, len(inputs))
|
||||||
|
|
||||||
|
logx.Printf("using %d threads\n", threads)
|
||||||
|
|
||||||
type job struct {
|
type job struct {
|
||||||
i int
|
i int
|
||||||
}
|
}
|
||||||
@@ -219,26 +225,18 @@ func run(_ context.Context, cmd *cli.Command) error {
|
|||||||
for w := 0; w < threads; w++ {
|
for w := 0; w < threads; w++ {
|
||||||
go func() {
|
go func() {
|
||||||
for j := range jobs {
|
for j := range jobs {
|
||||||
var logger *bytes.Buffer
|
var logger bytes.Buffer
|
||||||
|
|
||||||
if threads > 1 {
|
|
||||||
logger = bytes.NewBuffer(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
in := inputs[j.i]
|
in := inputs[j.i]
|
||||||
out := outputs[j.i]
|
out := outputs[j.i]
|
||||||
|
|
||||||
local := common
|
if err := processOne(in, out, cmd, &common, &logger); err != nil {
|
||||||
|
|
||||||
if err := processOne(in, out, cmd, &local, logger); err != nil {
|
|
||||||
errs <- fmt.Errorf("%s -> %s: %w", filepath.ToSlash(in), filepath.ToSlash(out), err)
|
errs <- fmt.Errorf("%s -> %s: %w", filepath.ToSlash(in), filepath.ToSlash(out), err)
|
||||||
} else {
|
} else {
|
||||||
errs <- nil
|
errs <- nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if threads > 1 {
|
logx.Print(logger.String())
|
||||||
logx.Print(logger.String())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user