[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sup-devel] [PATCH] Implement moving message between Maildir sources based on label.



With pleasure, I report that Sup is actually doing this!  So solving
the "hooks run too many times" is as easy as this:

commit ec3afe7ac01741bc67f68009193d2d2e73f05529
Author: Edward Z. Yang <ezyang@mit.edu>
Date:   Thu Aug 23 14:19:24 2012 -0400

    Don't run before-add-message hook for messages already in index.
    
    Signed-off-by: Edward Z. Yang <ezyang@mit.edu>

diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
index 1b64098..7d5aaa2 100644
--- a/lib/sup/poll.rb
+++ b/lib/sup/poll.rb
@@ -184,7 +184,7 @@ EOS
           m.labels.each { |l| LabelManager << l }
           m.labels = old_m.labels + (m.labels - [:unread, :inbox]) if old_m
           m.locations = old_m.locations + m.locations if old_m
-          HookManager.run "before-add-message", :message => m
+          HookManager.run "before-add-message", :message => m if not old_m
           yield :add, m, old_m, args[:progress] if block_given?
           Index.sync_message m, true
 


Excerpts from Alvaro Herrera's message of Thu Aug 23 10:52:21 -0400 2012:
> Excerpts from Edward Z. Yang's message of jue ago 23 10:40:22 -0400 2012:
> > It looks like the current patchset will *destroy* all labels you have
> > on messages, so be careful! (This was masked for me since most of my
> > labels are from before-add-message.rb, and that hook gets reapplied)
> 
> Thanks for the notice.  Most of my labels come from that hook too, but a
> few do not, so I could easily lose some!  I was planning on trying out
> your patch, but with this caveat I'm likely to refrain.  Are you
> planning on submitting a fixed version?
> 
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel