fix: handle zero size (#1888)

This commit is contained in:
Jason Song authored and GitHub committed 2023-07-10 20:35:27 -07:00
1 parent 724ec918c9
commit 8c7c0f53c1
3 files changed
+24 -11

No files matched your search

+4 -1
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 {