From ba3ed7b94512df0e30c9f5128a9ff34b2a4e5ac3 Mon Sep 17 00:00:00 2001 From: MickaelK Date: Fri, 14 Mar 2025 16:00:12 +1100 Subject: [PATCH] fix (plg_search_sqlitefs): context issue --- .../crawler/configuration.go | 4 ++-- .../plg_search_sqlitefts/crawler/events.go | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/server/plugin/plg_search_sqlitefts/crawler/configuration.go b/server/plugin/plg_search_sqlitefts/crawler/configuration.go index 9fa80c26..70dbe1de 100644 --- a/server/plugin/plg_search_sqlitefts/crawler/configuration.go +++ b/server/plugin/plg_search_sqlitefts/crawler/configuration.go @@ -33,8 +33,8 @@ var SEARCH_ENABLE = func() bool { "cycle_time", "max_size", "indexer_ext", } f.Description = "Enable/Disable full text search" - f.Placeholder = "Default: false" - f.Default = false + f.Placeholder = "Default: true" + f.Default = true return f }).Bool() } diff --git a/server/plugin/plg_search_sqlitefts/crawler/events.go b/server/plugin/plg_search_sqlitefts/crawler/events.go index d1348906..7b61e71f 100644 --- a/server/plugin/plg_search_sqlitefts/crawler/events.go +++ b/server/plugin/plg_search_sqlitefts/crawler/events.go @@ -4,7 +4,6 @@ import ( "container/heap" "context" "path/filepath" - "reflect" . "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):] } // 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 { Log.Warning("plg_search_sqlitefs::init message=cannot_create_crawler err=%s", err.Error()) return @@ -124,7 +129,7 @@ func (this *daemonState) HintLs(app *App, path string) { // recover from panic if one occurred. Set err to nil otherwise. if r := recover(); r != nil { name := "na" - for _, el := range app.Backend.LoginForm().Elmnts { + for _, el := range crawlerBackend.LoginForm().Elmnts { if el.Name == "type" { 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) } }() - 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{ Type: "directory", Path: path,