X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fpoll.rb;h=3a8b57fcda94dd78edb864e3ba7c7d0a2024ffe9;hb=01316aff4da1e7ff74dc3fac4578251b80807528;hp=d32c893e76771873832595ec95c67fac0780a208;hpb=51e9cd473399a0f2b810f5e1858539cf22a8fd9e;p=sup diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb index d32c893..3a8b57f 100644 --- a/lib/sup/poll.rb +++ b/lib/sup/poll.rb @@ -40,7 +40,7 @@ EOS end def buffer - b, new = BufferManager.spawn_unless_exists("", :hidden => true) { PollMode.new } + b, new = BufferManager.spawn_unless_exists("poll for new messages", :hidden => true, :system => true) { PollMode.new } b end @@ -97,13 +97,13 @@ EOS numi = 0 add_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 + m.labels = ((m.labels - [:unread, :inbox]) + entry[:label].symbolistize).uniq if entry yield "Found message at #{offset} with labels {#{m.labels * ', '}}" unless entry num += 1 - from_and_subj << [m.from.longname, m.subj] + from_and_subj << [m.from && m.from.longname, m.subj] if m.has_label?(:inbox) && ([:spam, :deleted, :killed] & m.labels).empty? - from_and_subj_inbox << [m.from.longname, m.subj] + from_and_subj_inbox << [m.from && m.from.longname, m.subj] numi += 1 end end @@ -134,7 +134,7 @@ EOS ## labels. it is likely that callers will want to replace these with ## the index 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_messages_from source + def add_messages_from source, opts={} begin return if source.done? || source.has_errors? @@ -157,7 +157,7 @@ EOS docid, entry = Index.load_entry_for_id m.id HookManager.run "before-add-message", :message => m m = yield(m, offset, entry) or next if block_given? - Index.sync_message m, docid, entry + Index.sync_message m, docid, entry, opts UpdateManager.relay self, :added, m unless entry rescue MessageFormatError => e Redwood::log "ignoring erroneous message at #{source}##{offset}: #{e.message}"