only fetch new pages fromm danbooru, if there are too few pending images
This commit is contained in:
parent
b0b74b52c7
commit
c4c4635700
|
@ -35,8 +35,7 @@ func (d DataSource) String() string {
|
|||
}
|
||||
|
||||
type FetchRequest struct {
|
||||
IsInitial bool
|
||||
Tag string
|
||||
Tag string
|
||||
}
|
||||
|
||||
// Generic error with prefix string
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue