Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH] poll: fix message update vs. already-imported detection
@ 2011-01-18 18:24 Sascha Silbe
  2011-01-19  3:39 ` Rich Lane
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Silbe @ 2011-01-18 18:24 UTC (permalink / raw)
  To: sup-devel

poll_from prepends existing locations to the "new" message, so we can't use
just the first location.

While using the last location would work, calculating the difference should be
fast and is more robust in the face of future changes to poll_from.

Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org>
---
 lib/sup/poll.rb |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
index afd3d95..7e05292 100644
--- a/lib/sup/poll.rb
+++ b/lib/sup/poll.rb
@@ -115,10 +115,11 @@ EOS
             yield "Deleting #{m.id}"
           elsif action == :add
             if old_m
-              if not old_m.locations.member? m.location
-                yield "Message at #{m.source_info} is an updated of an old message. Updating labels from #{old_m.labels.to_a * ','} => #{m.labels.to_a * ','}"
+              new_locations = (m.locations - old_m.locations)
+              if not new_locations.empty?
+                yield "Message at #{new_locations[0].info} is an update of an old message. Updating labels from #{old_m.labels.to_a * ','} => #{m.labels.to_a * ','}"
               else
-                yield "Skipping already-imported message at #{m.source_info}"
+                yield "Skipping already-imported message at #{m.locations[-1].info}"
               end
             else
               yield "Found new message at #{m.source_info} with labels #{m.labels.to_a * ','}"
-- 
1.7.2.3

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [sup-devel] [PATCH] poll: fix message update vs. already-imported detection
  2011-01-18 18:24 [sup-devel] [PATCH] poll: fix message update vs. already-imported detection Sascha Silbe
@ 2011-01-19  3:39 ` Rich Lane
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Lane @ 2011-01-19  3:39 UTC (permalink / raw)
  To: Sascha Silbe; +Cc: sup-devel

Applied to master.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-19  3:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18 18:24 [sup-devel] [PATCH] poll: fix message update vs. already-imported detection Sascha Silbe
2011-01-19  3:39 ` Rich Lane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox