From 5c96a2b2f23bf19ae3aaac1138dd702a288a9f82 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Fri, 30 Sep 2022 12:42:55 +0200 Subject: [PATCH] Fix crash in attachment handling when we close on error --- system/rest/attachment.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/rest/attachment.go b/system/rest/attachment.go index c1f0ab456..5dd463bc6 100644 --- a/system/rest/attachment.go +++ b/system/rest/attachment.go @@ -118,13 +118,13 @@ func (ctrl Attachment) serve(ctx context.Context, attachmentID uint64, preview, fh, err = ctrl.attachment.OpenOriginal(att) } - defer fh.Close() - if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } + defer fh.Close() + name := url.QueryEscape(att.Name) if download {