Skip to content

Commit

Permalink
Fix for locked DB error
Browse files Browse the repository at this point in the history
Should work. Does pause on Updating performers due to lack of log prints in that function
  • Loading branch information
pops64 committed Aug 29, 2024
1 parent 943283e commit c446c06
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions pkg/api/stashdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package api

import (
"net/http"
"time"

"github.com/emicklei/go-restful/v3"
"github.com/xbapps/xbvr/pkg/externalreference"
"github.com/xbapps/xbvr/pkg/scrape"
"github.com/xbapps/xbvr/pkg/models"
)

func (i ExternalReference) refreshStashPerformer(req *restful.Request, resp *restful.Response) {
Expand All @@ -32,13 +34,21 @@ func (i ExternalReference) stashRunAll(req *restful.Request, resp *restful.Respo

func StashdbRunAll() {
go func() {
scrape.StashDb()

externalreference.ApplySceneRules()
externalreference.MatchAkaPerformers()
externalreference.UpdateAllPerformerData()
tlog := log.WithField("task", "scrape")
tlog.Info("Stashdb Refresh Complete")

if !models.CheckLock("scrape") {
models.CreateLock("scrape")
defer models.RemoveLock("scrape")

t0 := time.Now()
tlog := log.WithField("task", "scrape")
tlog.Infof("StashDB Refresh started at %s", t0.Format("Mon Jan _2 15:04:05 2006"))
scrape.StashDb()

externalreference.ApplySceneRules()
externalreference.MatchAkaPerformers()
externalreference.UpdateAllPerformerData()
tlog = log.WithField("task", "scrape")
tlog.Infof("Stashdb Refresh Complete in %s",
time.Since(t0).Round(time.Second))
}
}()
}

0 comments on commit c446c06

Please sign in to comment.