From: Dan Callaghan <dan@bl2.djc.id.au>
To: sup-commits@supmua.dev
Subject: [sup.git] 03/08: show both raw and encoded sizes of attachments
Date: Sat, 28 Nov 2026 17:13:38 +1100 [thread overview]
Message-ID: <20261128061335.780AF2D45CD@bl2.djc.id.au> (raw)
In-Reply-To: <179584641514.302139.17817016268117078700@bl2.djc.id.au>
New commit on branch develop:
https://supmua.dev/git/sup/commit/9bfe7ee6169eb3e5c722112340291ca5a7ca73a7.html
commit 9bfe7ee6169eb3e5c722112340291ca5a7ca73a7
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Nov 21 14:50:28 2026 +1100
show both raw and encoded sizes of attachments
Also make the attachment line in edit-message-mode consistent with
thread-view-mode. Both will now display the content type, decoded byte
size, and encoded byte size (if it is different) in human friendly
units.
Fixes #457.
---
lib/sup/message_chunks.rb | 9 ++++++++-
lib/sup/modes/edit_message_mode.rb | 14 +++++++++++++-
test/test_message.rb | 12 ++++++++----
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/lib/sup/message_chunks.rb b/lib/sup/message_chunks.rb
index e9055d86..60ed47b6 100644
--- a/lib/sup/message_chunks.rb
+++ b/lib/sup/message_chunks.rb
@@ -95,6 +95,7 @@ EOS
@filename = filename
@quotable = false # changed to true if we can parse it through the
# mime-decode hook, or if it's plain text
+ @encoded_content = encoded_content
@raw_content =
if encoded_content.body
encoded_content.decode
@@ -141,7 +142,13 @@ EOS
if expandable?
"Attachment: #{filename} (#{lines.length} lines)"
else
- "Attachment: #{filename} (#{content_type}; #{@raw_content.size.to_human_size})"
+ raw_size = @raw_content.bytesize.to_human_size
+ encoded_size = @encoded_content.body.bytesize.to_human_size
+ if encoded_size == raw_size
+ "Attachment: #{filename} (#{content_type}; #{raw_size})"
+ else
+ "Attachment: #{filename} (#{content_type}; #{raw_size}; #{encoded_size} encoded)"
+ end
end
end
def safe_filename; Shellwords.escape(@filename).gsub("/", "_") end
diff --git a/lib/sup/modes/edit_message_mode.rb b/lib/sup/modes/edit_message_mode.rb
index aa3f4177..2cc8adaa 100644
--- a/lib/sup/modes/edit_message_mode.rb
+++ b/lib/sup/modes/edit_message_mode.rb
@@ -457,7 +457,19 @@ protected
unless @attachments.empty?
@text += [""]
@attachment_lines_offset = @text.length
- @text += (0 ... @attachments.size).map { |i| [[:attachment_color, "+ Attachment: #{@attachment_names[i]} (#{@attachments[i].body.size.to_human_size})"]] }
+ @text += (0 ... @attachments.size).map do |i|
+ name = @attachment_names[i]
+ content_type = @attachments[i].header.content_type
+ raw_size = @attachments[i].decode.bytesize.to_human_size
+ encoded_size = @attachments[i].body.bytesize.to_human_size
+ line =
+ if encoded_size == raw_size
+ "+ Attachment: #{name} (#{content_type}; #{raw_size})"
+ else
+ "+ Attachment: #{name} (#{content_type}; #{raw_size}; #{encoded_size} encoded)"
+ end
+ [[:attachment_color, line]]
+ end
end
end
diff --git a/test/test_message.rb b/test/test_message.rb
index 95b7378a..598aec31 100644
--- a/test/test_message.rb
+++ b/test/test_message.rb
@@ -112,13 +112,15 @@ class TestMessage < Minitest::Test
assert_equal(4, chunks.length)
assert(chunks[0].is_a? Redwood::Chunk::Quote)
+ assert_equal ["Excerpts from Fake Sender's message of Sun Dec 09 21:48:19 +0200 2007:",
+ "> Test message!"],
+ chunks[0].lines
assert(chunks[1].is_a? Redwood::Chunk::Text)
+ assert_equal ["", "Thanks for the message!"], chunks[1].lines
assert(chunks[2].is_a? Redwood::Chunk::Attachment)
+ assert_equal "Attachment: HACKING (application/octet-stream; 627B; 850B encoded)", chunks[2].patina_text
assert(chunks[3].is_a? Redwood::Chunk::Attachment)
-
- # further testing of chunks will happen in test_message_chunks.rb
- # (possibly not yet implemented)
-
+ assert_equal "Attachment: Manifest.txt (13 lines)", chunks[3].patina_text
end
def test_broken_message_1
@@ -170,6 +172,8 @@ class TestMessage < Minitest::Test
assert_equal(1, chunks.length)
assert(chunks[0].is_a? Redwood::Chunk::Attachment)
+ assert_match(/^Attachment: sup-attachment-\d+-\d+\.html \(text\/html; 635B; 661B encoded\)$/,
+ chunks[0].patina_text)
end
def test_text_attachment_decoding
next prev parent reply other threads:[~2026-11-28 6:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
2026-11-28 6:13 ` [sup.git] 01/08: delete dead report_broken_sources method Dan Callaghan
2026-11-28 6:13 ` [sup.git] 02/08: sup-sync-back-maildir: remove broken negative short options Dan Callaghan
2026-11-28 6:13 ` Dan Callaghan [this message]
2026-11-28 6:13 ` [sup.git] 04/08: shell escape bounce destination addresses Dan Callaghan
2026-11-28 6:13 ` [sup.git] 05/08: call setlocale() through ncurses bindings instead of fiddle Dan Callaghan
2026-11-28 6:13 ` [sup.git] 06/08: use libmagic to detect attachment MIME types Dan Callaghan
2026-11-28 6:13 ` [sup.git] 07/08: clean up directory traversal in Maildir#poll Dan Callaghan
2026-11-28 6:13 ` [sup.git] 08/08: bring back sup-recover-sources from the dead Dan Callaghan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261128061335.780AF2D45CD@bl2.djc.id.au \
--to=dan@bl2.djc.id.au \
--cc=djc@djc.id.au \
--cc=sup-commits@supmua.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox