fix: failed to save bookmark: context canceled (#499)

When the HTTP request completes, the asynchronous bookmarks save may be incomplete.
In this case, the shared context is canceled and saving bookmarks fails.

Introduced by 09f2465065
This commit is contained in:
Acelya 2022-10-11 18:08:21 +02:00 committed by GitHub
parent 222fc14fe2
commit 040dc5c5d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
package webserver
import (
"context"
"encoding/json"
"fmt"
"log"
@ -326,7 +327,7 @@ func (h *handler) apiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h
if err != nil {
log.Printf("error downloading boorkmark: %s", err)
}
if _, err := h.DB.SaveBookmarks(ctx, *bookmark); err != nil {
if _, err := h.DB.SaveBookmarks(context.Background(), *bookmark); err != nil {
log.Printf("failed to save bookmark: %s", err)
}
}()