fix: ignore cancellation errors from user aborts

pull/4716/head
manx98 2025-05-26 22:00:24 +08:00
parent 791e8638ac
commit f801086b03
1 changed files with 4 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package http
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"errors"
"github.com/filebrowser/filebrowser/v2/search" "github.com/filebrowser/filebrowser/v2/search"
"net/http" "net/http"
"os" "os"
@ -25,7 +26,7 @@ var searchHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *dat
var infoBytes []byte var infoBytes []byte
select { select {
case info := <-response: case info := <-response:
if (info) == nil { if info == nil {
return return
} }
infoBytes, err = json.Marshal(info) infoBytes, err = json.Marshal(info)
@ -69,7 +70,8 @@ var searchHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *dat
if err == nil { if err == nil {
err = context.Cause(ctx) 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 return http.StatusInternalServerError, err
} }