From 7fde67aea57040ba2676fb690e3db83e1d1db726 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 17 Jan 2024 17:16:12 -0500 Subject: [PATCH] fix: use PinByID and pin after creating the upload --- api/s5/http.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/s5/http.go b/api/s5/http.go index aec1367..bd6c03d 100644 --- a/api/s5/http.go +++ b/api/s5/http.go @@ -186,7 +186,13 @@ func (h *HttpHandler) SmallFileUpload(jc jape.Context) { return } - _, err = h.portal.Storage().CreateUpload(hash, uint(jc.Request.Context().Value(AuthUserIDKey).(uint64)), jc.Request.RemoteAddr, uint64(bufferSize), "s5") + upload, err := h.portal.Storage().CreateUpload(hash, uint(jc.Request.Context().Value(AuthUserIDKey).(uint64)), jc.Request.RemoteAddr, uint64(bufferSize), "s5") + if err != nil { + _ = jc.Error(errUploadingFileErr, http.StatusInternalServerError) + h.portal.Logger().Error(errUploadingFile, zap.Error(err)) + } + + err = h.portal.Accounts().PinByID(upload.ID, uint(jc.Request.Context().Value(AuthUserIDKey).(uint64))) if err != nil { _ = jc.Error(errUploadingFileErr, http.StatusInternalServerError) h.portal.Logger().Error(errUploadingFile, zap.Error(err))