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,12 +387,13 @@ func (h *Handler) get(w http.ResponseWriter, r *http.Request, params httprouter.
|
|||
}
|
||||
|
||||
cache := &Cache{}
|
||||
{
|
||||
db, err := h.openDB()
|
||||
if err != nil {
|
||||
h.responseJSON(w, r, 500, fmt.Errorf("cache openDB: %w", err))
|
||||
return
|
||||
}
|
||||
db.Close()
|
||||
defer db.Close()
|
||||
if err := db.Get(id, cache); err != nil {
|
||||
if errors.Is(err, bolthold.ErrNotFound) {
|
||||
h.responseJSON(w, r, 404, fmt.Errorf("cache %d: not reserved", id))
|
||||
|
@ -401,6 +402,7 @@ func (h *Handler) get(w http.ResponseWriter, r *http.Request, params httprouter.
|
|||
h.responseJSON(w, r, 500, fmt.Errorf("cache Get: %w", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Should not happen
|
||||
if cache.Repo != repo {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue