@@ -2,9 +2,11 @@ package api
2
2
3
3
import (
4
4
"net/http"
5
+ "time"
5
6
6
7
"github.com/emicklei/go-restful/v3"
7
8
"github.com/xbapps/xbvr/pkg/externalreference"
9
+ "github.com/xbapps/xbvr/pkg/models"
8
10
"github.com/xbapps/xbvr/pkg/scrape"
9
11
)
10
12
@@ -32,13 +34,21 @@ func (i ExternalReference) stashRunAll(req *restful.Request, resp *restful.Respo
32
34
33
35
func StashdbRunAll () {
34
36
go func () {
35
- scrape .StashDb ()
36
-
37
- externalreference .ApplySceneRules ()
38
- externalreference .MatchAkaPerformers ()
39
- externalreference .UpdateAllPerformerData ()
40
- tlog := log .WithField ("task" ,"scrape" )
41
- tlog .Info ("Stashdb Refresh Complete" )
42
-
37
+ if ! models .CheckLock ("scrape" ) {
38
+ models .CreateLock ("scrape" )
39
+ defer models .RemoveLock ("scrape" )
40
+
41
+ t0 := time .Now ()
42
+ tlog := log .WithField ("task" ,"scrape" )
43
+ tlog .Infof ("StashDB Refresh started at %s" ,t0 .Format ("Mon Jan _2 15:04:05 2006" ))
44
+ scrape .StashDb ()
45
+
46
+ externalreference .ApplySceneRules ()
47
+ externalreference .MatchAkaPerformers ()
48
+ externalreference .UpdateAllPerformerData ()
49
+ tlog = log .WithField ("task" ,"scrape" )
50
+ tlog .Infof ("Stashdb Refresh Complete in %s" ,
51
+ time .Since (t0 ).Round (time .Second ))
52
+ }
43
53
}()
44
54
}