#221: summary pill size must come from the attachment blob for file pastes
The merged #224 fix covered the details grid but left the summary pill using humanSize(len(row.Content)), which reads 0 for attachment pastes (text content is empty). Use the attachment size there too.
This commit is contained in:
+8
-1
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user