Subject: [sup-talk] sup crashing after sending mail

From: [email-masked] (William Morgan)
Date: Wed, 05 Aug 2009 08:29:27 -0700

Hi Igor,

Reformatted excerpts from Igor Brkic's message of 2009-08-02:
> For mail sending I use sSMTP and my ISP's SMTP server. When I try to
> send mail from sup, after pressing y on keyboard, mail gets sent but
> sup crashes (exception-log_0.txt in attachment).

A few people have reported this and I'm trying to track it down. Would
you mind applying the following patch, and then running:
  sup-sync -a sup://sent

Hopefully that will generate a little debugging output I can use. Thanks!

diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index 5372fc7..fc9af59 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -92,11 +92,11 @@ class Message
       begin
         Time.parse date
       rescue ArgumentError => e
-        #Redwood::log "faking mangled date header for #{@id} (orig #{header['date']
+        Redwood::log "faking mangled date header for #{@id} (orig #{header['date'].
         Time.now
       end
     else
-      #Redwood::log "faking non-existent date header for #{@id}"
+      Redwood::log "faking non-existent date header for #{@id}"
       Time.now
     end
 
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
index 354bd21..365f828 100644
--- a/lib/sup/poll.rb
+++ b/lib/sup/poll.rb
@@ -148,7 +148,9 @@ EOS
         labels = labels + (source.archived? ? [] : [:inbox])
 
         m = Message.new :source => source, :source_info => offset, :labels => label
+        Redwood::log "XX before load: #{m.date.inspect}"
         m.load_from_source!
+        Redwood::log "XX after load: #{m.date.inspect}"
 
         if m.source_marked_read?
           m.remove_label :unread
@@ -157,7 +159,9 @@ EOS
 
         docid, entry = Index.load_entry_for_id m.id
         HookManager.run "before-add-message", :message => m
+        Redwood::log "XX after add-message: #{m.date.inspect}"
         m = yield(m, offset, entry) or next if block_given?
+        Redwood::log "XX after yield: #{m.date.inspect}"
         times = Index.sync_message m, false, docid, entry, opts
         UpdateManager.relay self, :added, m unless entry
       end

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Igor Brkic)
Date: Thu, 06 Aug 2009 01:24:38 +0200

> Hopefully that will generate a little debugging output I can use. Thanks!

I (partially) solved/hacked the problem. The problem was (I think) in wrong
set locale and Sup not being able to recognize and compare sending date
(which had croatian tags for month and day of the week) and Time.now (which
was whole in english/universal format).

I solved the problem by commenting out the "Time.parse time, 0" (line 15 in
file lib/sup/mbox.rb).

It's not perfect solution (if that line should be commented out, it would
be :D), but for me it works for now (I'm writing this mail from it).

Cheers!
Igor Brkic

---

From: [email-masked] (William Morgan)
Date: Thu, 06 Aug 2009 07:40:08 -0700

Reformatted excerpts from Igor Brkic's message of 2009-08-05:
> I solved the problem by commenting out the "Time.parse time, 0" (line
> 15 in file lib/sup/mbox.rb).

I'm glad that works, but I have a hard time understanding why.

That line is for parsing the mbox "From " separator line (which has a
date on it). It has nothing to do with the date field in the message,
which is what isn't being set (and thus raising the exception).

If the date parsing on that line is screwed up, then I would except to
see an out-of-sync error raised by Sup, since it would be expecting an
mbox "From " separator line and wouldn't detect the line as such.

If you feel like it, send me a small mbox file (possible your
~/.sup/sent.mbox after being censored) and I can take a look.
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Igor Brkic)
Date: Thu, 06 Aug 2009 18:57:03 +0200

> ~/.sup/sent.mbox after being censored) and I can take a look.

This is weird... For the last hour and a half I've been trying to
reproduce the error I was having - I uncommented the line in mbox.rb,
returned locale settings to previous state - but everything is working 
flawless. Whatever I make, it won't crash. I'll keep trying, though :)

I'm afraid I can't send you the mbox file that is causing sup to crash
because I deleted all logs and sent.mbox files the moment all started
to work.

---

From: [email-masked] (William Morgan)
Date: Thu, 06 Aug 2009 10:45:50 -0700

Reformatted excerpts from Igor Brkic's message of 2009-08-06:
> I attached output of "sup-sync -a sup://sent" with patch you sent me
> applyed (sync-log.txt).

Awesome. This looks very juicy. Thanks!
-- 
William <wmorgan-sup at masanjin.net>