snarf_mail: Fix total count of all messages
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 3 May 2010 19:55:31 +0000 (12:55 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 3 May 2010 19:55:31 +0000 (12:55 -0700)
snarf_mail.rb

index bfc0873..ca871f8 100755 (executable)
@@ -87,6 +87,7 @@ end
 def snarf_mailbox(imap, mailbox)
        imap.select(mailbox)
        count = 0
+  total_count = 0
        imap.search(["NOT", "DELETED"]).each do |message_id|
                data = imap.fetch(message_id, [ "UID", "RFC822.HEADER", "RFC822.TEXT" ])
                a = data[0].attr
@@ -96,13 +97,14 @@ def snarf_mailbox(imap, mailbox)
                fp.write(a["RFC822.TEXT"])
                fp.close
                count = count + 1
+    total_count = total_count + 1
                if (count > 10) then
                        count = 0
                        printf(".")
                        STDOUT.flush()
                end
        end
-       puts "fetched #{count} messages from #{mailbox}"
+       puts "fetched #{total_count} messages from #{mailbox}"
 end
 
 # MAIN