Skip to content

Commit

Permalink
fix: Fix for locked DB error (#1834)
Browse files Browse the repository at this point in the history
* Fix for locked DB error

Should work. Does pause on Updating performers due to lack of log prints in that function

* go fmt
  • Loading branch information
pops64 authored Oct 11, 2024
1 parent bc2b112 commit 4f274d9
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,9 +2,11 @@ package api

import (
"net/http"
"time"

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

Expand Down Expand Up @@ -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 4f274d9

Please sign in to comment.