Fix #221 follow-up: summary pill size for attachment pastes #228

Merged
fen merged 1 commits from fix-221-r2 into dev 2026-09-10 19:33:51 +00:00
Showing only changes of commit d18bbb7064 - Show all commits
+8 -1
View File
@@ -245,13 +245,20 @@ func (h *Handlers) renderPaste(w http.ResponseWriter, row *store.PasteRow, justC
if lang == "" { if lang == "" {
lang = "text" lang = "text"
} }
summary := fmt.Sprintf("%s · %s · %d views · %s", lang, humanSize(len(row.Content)), row.ViewCount, agoString(row.CreatedAt))
// #38: one optional file attachment per paste; nil when none. // #38: one optional file attachment per paste; nil when none.
attachment, err := h.Store.GetAttachmentForPaste(row.ID) attachment, err := h.Store.GetAttachmentForPaste(row.ID)
if err != nil { if err != nil {
http.Error(w, "db error", 500) http.Error(w, "db error", 500)
return return
} }
// #221: for attachment pastes the stored text content is empty (the file
// replaced it), so the summary size must come from the attachment blob,
// not len(row.Content), or the summary shows "0 B".
summarySize := len(row.Content)
if attachment != nil {
summarySize = int(attachment.Size)
}
summary := fmt.Sprintf("%s · %s · %d views · %s", lang, humanSize(summarySize), row.ViewCount, agoString(row.CreatedAt))
// #221: image attachments render the image, not a text/code box. Size // #221: image attachments render the image, not a text/code box. Size
// comes from the attachment's actual file size, not the text content. // comes from the attachment's actual file size, not the text content.
attImage := false attImage := false