Merge pull request 'Fix #221 follow-up: summary pill size for attachment pastes' (#228) from fix-221-r2 into dev
This commit was merged in pull request #228.
This commit is contained in:
+8
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user