mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
fix: do not immediately close the db after opening it
This commit is contained in:
parent
187e1df52c
commit
639b83c26c
1 changed files with 13 additions and 11 deletions
|
@ -387,19 +387,21 @@ func (h *Handler) get(w http.ResponseWriter, r *http.Request, params httprouter.
|
||||||
}
|
}
|
||||||
|
|
||||||
cache := &Cache{}
|
cache := &Cache{}
|
||||||
db, err := h.openDB()
|
{
|
||||||
if err != nil {
|
db, err := h.openDB()
|
||||||
h.responseJSON(w, r, 500, fmt.Errorf("cache openDB: %w", err))
|
if err != nil {
|
||||||
return
|
h.responseJSON(w, r, 500, fmt.Errorf("cache openDB: %w", err))
|
||||||
}
|
return
|
||||||
db.Close()
|
}
|
||||||
if err := db.Get(id, cache); err != nil {
|
defer db.Close()
|
||||||
if errors.Is(err, bolthold.ErrNotFound) {
|
if err := db.Get(id, cache); err != nil {
|
||||||
h.responseJSON(w, r, 404, fmt.Errorf("cache %d: not reserved", id))
|
if errors.Is(err, bolthold.ErrNotFound) {
|
||||||
|
h.responseJSON(w, r, 404, fmt.Errorf("cache %d: not reserved", id))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.responseJSON(w, r, 500, fmt.Errorf("cache Get: %w", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h.responseJSON(w, r, 500, fmt.Errorf("cache Get: %w", err))
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should not happen
|
// Should not happen
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue