From bcd14fe2279d8c4d38270b0dc647eab97a8991ed Mon Sep 17 00:00:00 2001 From: Matthieu Rakotojaona Date: Sat, 26 Jul 2014 22:44:19 +0200 Subject: [PATCH] Implement drafts for all sources We just have to provide the relevant filename for the message to edit, and then remove the :draft label from the message when all is done. --- lib/sup/draft.rb | 5 ++--- lib/sup/maildir.rb | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/sup/draft.rb b/lib/sup/draft.rb index 7266e0aad..cc8c302c3 100644 --- a/lib/sup/draft.rb +++ b/lib/sup/draft.rb @@ -20,10 +20,9 @@ def write_draft PollManager.poll_from @source end + # This works for all sources, not only sup://drafts def discard m - raise ArgumentError, "not a draft: source id #{m.source.id.inspect}, should be #{DraftManager.source_id.inspect} for #{m.id.inspect}" unless m.source.id.to_i == DraftManager.source_id - Index.delete m.id - File.delete @source.fn_for_offset(m.source_info) rescue Errono::ENOENT + m.remove_label :draft UpdateManager.relay self, :single_message_deleted, m end end diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb index 84236beed..d014d89be 100644 --- a/lib/sup/maildir.rb +++ b/lib/sup/maildir.rb @@ -193,6 +193,10 @@ def valid? id File.exists? File.join(@dir, id) end + def fn_for_offset offset + return File.join(@dir, offset) + end + private def new_maildir_basefn