From f801086b039c3d3580d54dcf1f862954a324da25 Mon Sep 17 00:00:00 2001 From: manx98 <1323517022@qq.com> Date: Mon, 26 May 2025 22:00:24 +0800 Subject: [PATCH] fix: ignore cancellation errors from user aborts --- http/search.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/http/search.go b/http/search.go index 555b00d6..aae87de1 100644 --- a/http/search.go +++ b/http/search.go @@ -3,6 +3,7 @@ package http import ( "context" "encoding/json" + "errors" "github.com/filebrowser/filebrowser/v2/search" "net/http" "os" @@ -25,7 +26,7 @@ var searchHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *dat var infoBytes []byte select { case info := <-response: - if (info) == nil { + if info == nil { return } infoBytes, err = json.Marshal(info) @@ -69,7 +70,8 @@ var searchHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *dat if err == nil { err = context.Cause(ctx) } - if err != nil { + // ignore cancellation errors from user aborts + if err != nil && !errors.Is(err, context.Canceled) { return http.StatusInternalServerError, err }