commit b45108bb0fa37b2005c384654f9b2a2cbd0a0c3e
parent 856b51815234b574205a7091e2e9c37da07f9a2c
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Sat, 10 Feb 2007 16:29:27 +0000
poll tweaks
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@312 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/bin/sup-import b/bin/sup-import
@@ -107,8 +107,8 @@ begin
m
elsif opts[:full_rebuild] || # we're updating everyone; or
(opts[:rebuild] && (entry[:source_id].to_i != source.id || entry[:source_info].to_i != offset)) # we're updating just the changed ones
- puts "# updating message at #{offset}, #{m.from.inspect}, #{m.subj.inspect}, source #{entry[:source_id]} => #{source.id}, offset #{entry[:source_info]} => #{offset}, labels: #{m.labels * ' '}" if opts[:verbose]
- num += 1
+ puts "# updating message at #{offset} (from #{m.from.longname} subject \"#{m.subj}\"), source #{entry[:source_id]} => #{source.id}, offset #{entry[:source_info]} => #{offset}, labels: {#{m.labels * ', '}}" if opts[:verbose]
+ num += 1 unless found[m.id]
m
else
nil
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
@@ -41,7 +41,6 @@ class PollManager
def do_poll
total_num = total_numi = 0
@mutex.synchronize do
- found = {}
Index.usual_sources.each do |source|
# yield "source #{source} is done? #{source.done?} (cur_offset #{source.cur_offset} >= #{source.end_offset})"
yield "Loading from #{source}... " unless source.done? || source.broken?
@@ -50,7 +49,7 @@ class PollManager
add_new_messages_from source do |m, offset, entry|
## always preserve the labels on disk.
m.labels = entry[:label].split(/\s+/).map { |x| x.intern } if entry
- yield "Found message at #{offset} with labels #{m.labels * ', '}"
+ yield "Found message at #{offset} with labels {#{m.labels * ', '}}"
num += 1
numi += 1 if m.labels.include? :inbox
m
@@ -80,7 +79,6 @@ class PollManager
## labels, if they exist, so that state is not lost when e.g. a new
## version of a message from a mailing list comes in.
def add_new_messages_from source
- found = {}
return if source.done? || source.broken?
source.each do |offset, labels|
@@ -93,13 +91,6 @@ class PollManager
begin
m = Message.new :source => source, :source_info => offset, :labels => labels
- if found[m.id]
- Redwood::log "skipping duplicate message #{m.id}"
- next
- else
- found[m.id] = true
- end
-
if m.source_marked_read?
m.remove_label :unread
labels.delete :unread