fix (plg_search_sqlitefs): context issue

This commit is contained in:
MickaelK 2025-03-14 16:00:12 +11:00
parent afbceabad2
commit ba3ed7b945
2 changed files with 10 additions and 12 deletions

View file

@ -33,8 +33,8 @@ var SEARCH_ENABLE = func() bool {
"cycle_time", "max_size", "indexer_ext", "cycle_time", "max_size", "indexer_ext",
} }
f.Description = "Enable/Disable full text search" f.Description = "Enable/Disable full text search"
f.Placeholder = "Default: false" f.Placeholder = "Default: true"
f.Default = false f.Default = true
return f return f
}).Bool() }).Bool()
} }

View file

@ -4,7 +4,6 @@ import (
"container/heap" "container/heap"
"context" "context"
"path/filepath" "path/filepath"
"reflect"
. "github.com/mickael-kerjean/filestash/server/common" . "github.com/mickael-kerjean/filestash/server/common"
) )
@ -115,7 +114,13 @@ func (this *daemonState) HintLs(app *App, path string) {
this.idx = this.idx[lenIdx-(search_process_max-1):] this.idx = this.idx[lenIdx-(search_process_max-1):]
} }
// instantiate the new indexer // instantiate the new indexer
s, err := NewCrawler(id, app.Backend) app.Context = context.Background()
crawlerBackend, err := app.Backend.Init(app.Session, app)
if err != nil {
Log.Warning("plg_search_sqlitefs::init message=cannot_create_crawler err=%s", err.Error())
return
}
s, err := NewCrawler(id, crawlerBackend)
if err != nil { if err != nil {
Log.Warning("plg_search_sqlitefs::init message=cannot_create_crawler err=%s", err.Error()) Log.Warning("plg_search_sqlitefs::init message=cannot_create_crawler err=%s", err.Error())
return return
@ -124,7 +129,7 @@ func (this *daemonState) HintLs(app *App, path string) {
// recover from panic if one occurred. Set err to nil otherwise. // recover from panic if one occurred. Set err to nil otherwise.
if r := recover(); r != nil { if r := recover(); r != nil {
name := "na" name := "na"
for _, el := range app.Backend.LoginForm().Elmnts { for _, el := range crawlerBackend.LoginForm().Elmnts {
if el.Name == "type" { if el.Name == "type" {
name = el.Value.(string) name = el.Value.(string)
} }
@ -132,13 +137,6 @@ func (this *daemonState) HintLs(app *App, path string) {
Log.Error("plg_search_sqlitefs::panic backend=\"%s\" recover=\"%s\"", name, r) Log.Error("plg_search_sqlitefs::panic backend=\"%s\" recover=\"%s\"", name, r)
} }
}() }()
v := reflect.ValueOf(app.Backend).Elem().FieldByName("Context")
if v.IsValid() && v.CanSet() {
// prevent context expiration which is often default as r.Context()
// as we need to make queries outside the scope of a normal http request
v.Set(reflect.ValueOf(context.Background()))
}
heap.Push(&s.FoldersUnknown, &Document{ heap.Push(&s.FoldersUnknown, &Document{
Type: "directory", Type: "directory",
Path: path, Path: path,