better jobs queue

This commit is contained in:
ston1th 2022-10-06 18:48:41 +02:00
commit cca34832b7
2 changed files with 23 additions and 15 deletions

View file

@ -166,7 +166,7 @@ func indexHandler(ctx *Context) {
if fpath, ok = hasTrimPrefix(path, core.IndexPrefix); ok {
log = log.WithValues("file", fpath)
log.V(2).Info("started indexing file")
err = ctx.Srv.SQ.Add(fpath)
err = ctx.Srv.SQ.Add(fpath, nil)
if err != nil {
log.Error(err, "error indexing file")
}
@ -214,12 +214,11 @@ func indexHandler(ctx *Context) {
ctx.Srv.DB.IndexMutex.Set(uint64(len(files)))
for _, f := range files {
if !ctx.Srv.DB.IsIndexed(f) {
err := ctx.Srv.SQ.Add(f)
err := ctx.Srv.SQ.Add(f, ctx.Srv.DB.IndexMutex.Inc)
if err != nil {
log.Error(err, "error indexing file", "file", f)
}
}
ctx.Srv.DB.IndexMutex.Inc()
}
}()
} else {