✨ 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
|
package convids
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -48,6 +49,7 @@ func WalkFiles(d *Data, stopOnError bool, gp GroupPrinter, cb ShowWalker) (err e
|
||||||
}
|
}
|
||||||
for s := range d.AllShows(gp) {
|
for s := range d.AllShows(gp) {
|
||||||
var found bool
|
var found bool
|
||||||
|
start:
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if file.IsDir() {
|
if file.IsDir() {
|
||||||
continue
|
continue
|
||||||
|
|
@ -59,13 +61,27 @@ func WalkFiles(d *Data, stopOnError bool, gp GroupPrinter, cb ShowWalker) (err e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if found {
|
if !found {
|
||||||
err = cb(s, fp.Join(d.Config.Source, file.Name()))
|
continue
|
||||||
if err != nil && stopOnError {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ type Config struct {
|
||||||
Source string
|
Source string
|
||||||
Extensions []string
|
Extensions []string
|
||||||
Groups []string
|
Groups []string
|
||||||
|
Skip []string
|
||||||
|
|
||||||
extRe *regexp.Regexp
|
extRe *regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue