diff --git a/internal/web/web.go b/internal/web/web.go index 08f84ce..e484073 100644 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -245,13 +245,20 @@ func (h *Handlers) renderPaste(w http.ResponseWriter, row *store.PasteRow, justC if lang == "" { 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. attachment, err := h.Store.GetAttachmentForPaste(row.ID) if err != nil { http.Error(w, "db error", 500) 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 // comes from the attachment's actual file size, not the text content. attImage := false