fix: handle zero size (#1888)

This commit is contained in:
Jason Song
2023-07-11 11:35:27 +08:00
committed by GitHub
parent 724ec918c9
commit 8c7c0f53c1
3 changed files with 24 additions and 11 deletions

View File

@@ -311,10 +311,13 @@ func (h *Handler) commit(w http.ResponseWriter, r *http.Request, params httprout
db.Close()
if err := h.storage.Commit(cache.ID, cache.Size); err != nil {
size, err := h.storage.Commit(cache.ID, cache.Size)
if err != nil {
h.responseJSON(w, r, 500, err)
return
}
// write real size back to cache, it may be different from the current value when the request doesn't specify it.
cache.Size = size
db, err = h.openDB()
if err != nil {