✨ Skip downloading files in convids
This commit is contained in:
parent
d5e7f601b6
commit
729e1d4dcc
2 changed files with 23 additions and 6 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package convids
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
|
@ -48,6 +49,7 @@ func WalkFiles(d *Data, stopOnError bool, gp GroupPrinter, cb ShowWalker) (err e
|
|||
}
|
||||
for s := range d.AllShows(gp) {
|
||||
var found bool
|
||||
start:
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
continue
|
||||
|
|
@ -59,13 +61,27 @@ func WalkFiles(d *Data, stopOnError bool, gp GroupPrinter, cb ShowWalker) (err e
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
if found {
|
||||
err = cb(s, fp.Join(d.Config.Source, file.Name()))
|
||||
if err != nil && stopOnError {
|
||||
return
|
||||
}
|
||||
break
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
|
||||
path := fp.Join(d.Config.Source, file.Name())
|
||||
for _, ext := range d.Config.Skip {
|
||||
if !strings.HasPrefix(ext, ".") {
|
||||
ext = "." + ext
|
||||
}
|
||||
skipper := path + ext
|
||||
_, err := os.Stat(skipper)
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
break start
|
||||
}
|
||||
}
|
||||
|
||||
err = cb(s, path)
|
||||
if err != nil && stopOnError {
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue