only fetch new pages fromm danbooru, if there are too few pending images

This commit is contained in:
bakape 2020-11-22 15:41:20 +02:00
parent b0b74b52c7
commit c4c4635700
No known key found for this signature in database
GPG Key ID: F91DA82BD0B67F74
3 changed files with 6 additions and 14 deletions

View File

@ -35,8 +35,7 @@ func (d DataSource) String() string {
}
type FetchRequest struct {
IsInitial bool
Tag string
Tag string
}
// Generic error with prefix string

View File

@ -46,18 +46,12 @@ func Fetch(req common.FetchRequest) (f *os.File, image db.Image, err error) {
mu.Lock()
defer mu.Unlock()
// Faster tag init
skipPageFetch := false
allFetched := false
if req.IsInitial {
var n int
n, err = db.CountPending(req.Tag)
if err != nil {
return
}
skipPageFetch = n >= 3
pending, err := db.CountPending(req.Tag)
if err != nil {
return
}
if !skipPageFetch {
allFetched := false
if pending < 3 {
err = tryFetchPage(req.Tag, req.Tag+" solo")
switch err {
case nil:

View File

@ -200,7 +200,6 @@ func (s *Service) initTag(tag string) (err error) {
f = s.filters(tag)
req = f.FetchRequest
)
req.IsInitial = true
for {
count, err = db.ImageCount(f)
if err != nil {