From: brabuhr@gmail.com (brabuhr)
Subject: [sup-talk] [PATCH] expand file paths and rescue enoent exceptions when adding attachments
Date: Sat, 26 Jan 2008 22:35:44 -0500 [thread overview]
Message-ID: <21aa9f0801261935i12a36782o85030b24078e7dd7@mail.gmail.com> (raw)
In-Reply-To: <21aa9f0801261918j2890aee2yeb52484a95b786c3@mail.gmail.com>
On 1/26/08, Daniel Wagner <daniel at wagner-home.com> wrote:
> If I type in a filename that starts with ~ at the attachment prompt, sup
> crashes.
---
lib/sup/modes/edit-message-mode.rb | 4 ++++
lib/sup/util.rb | 3 ++-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/lib/sup/modes/edit-message-mode.rb
b/lib/sup/modes/edit-message-mode.rb
index 6a7f273..9412235 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -151,6 +151,10 @@ EOS
@attachments << RMail::Message.make_file_attachment(fn)
@attachment_names << fn
update
+ rescue Errno::ENOENT => e
+ Redwood::log "Cannot add attachment: #{e.message}"
+ Redwood::log e.backtrace.join("\n")
+ Redwood::BufferManager.flash "Could not add attachment: #{e.message}"
end
def delete_attachment
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
index ceaf0b8..51339d6 100644
--- a/lib/sup/util.rb
+++ b/lib/sup/util.rb
@@ -57,8 +57,9 @@ module RMail
class Message
def self.make_file_attachment fn
bfn = File.basename fn
+ fp = File.expand_path fn
t = MIME::Types.type_for(bfn).first || MIME::Types.type_for
("exe").first
- make_attachment IO.read(fn), t.content_type, t.encoding, bfn.to_s
+ make_attachment IO.read(fp), t.content_type, t.encoding, bfn.to_s
end
def charset
--
1.5.2.5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/sup-talk/attachments/20080126/533da985/attachment.html
next parent reply other threads:[~2008-01-27 3:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <21aa9f0801261918j2890aee2yeb52484a95b786c3@mail.gmail.com>
2008-01-27 3:35 ` brabuhr [this message]
2008-02-03 2:20 ` William Morgan
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=21aa9f0801261935i12a36782o85030b24078e7dd7@mail.gmail.com \
--to=brabuhr@gmail.com \
/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