Subject: [sup-talk] [PATCH] Bug fixes and speed improvements for maildir handling.

From: [email-masked] (Mark Alexander)
Date: Tue, 21 Apr 2009 08:43:44 -0700

---
 lib/sup/maildir.rb |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
index 3d584f7..d74279a 100644
--- a/lib/sup/maildir.rb
+++ b/lib/sup/maildir.rb
@@ -10,6 +10,7 @@ module Redwood

 class Maildir < Source
   SCAN_INTERVAL = 30 # seconds
+  TIME_SCALE = 10000000

   ## remind me never to use inheritance again.
   yaml_properties :uri, :cur_offset, :usual, :archived, :id, :labels, :mtimes
@@ -123,8 +124,11 @@ class Maildir < Source
     return unless start_offset

     start = @ids.index(cur_offset || start_offset) or raise
OutOfSyncSourceError, "Unknown message id #{cur_offset ||
start_offset}." # couldn't find the most recent email
+    if cur_offset
+       start += 1
+    end

-    start.upto(@ids.length - 1) do |i|
+    (start... at ids.length).each do |i|
       id = @ids[i]
       self.cur_offset = id
       yield id, @labels + (seen?(id) ? [] : [:unread]) +
(trashed?(id) ? [:deleted] : []) + (flagged?(id) ? [:starred] : [])
@@ -138,7 +142,7 @@ class Maildir < Source

   def end_offset
     scan_mailbox :rescan => true
-    @ids.last + 1
+    ((@ids.last / TIME_SCALE) + 1) * TIME_SCALE
   end

   def pct_done; 100.0 * (@ids.index(cur_offset) || 0).to_f /
(@ids.length - 1).to_f; end
@@ -164,7 +168,7 @@ private
     #makes a noticeable difference on nfs.
     stat = File.stat(fn)
     # use 7 digits for the size. why 7? seems nice.
-    sprintf("%d%07d", stat.mtime, stat.size % 10000000).to_i
+    (stat.mtime.to_i * TIME_SCALE) + (stat.size % TIME_SCALE)
   end

   def with_file_for id
-- 
1.6.1.28.gc32f76

---

From: [email-masked] (William Morgan)
Date: Mon, 04 May 2009 07:28:43 -0700

>  1 files changed, 7 insertions(+), 3 deletions(-)

I think I'm going to drop this patch, as the Maildir code is going to
get changed in other ways very shortly.
-- 
William <wmorgan-sup at masanjin.net>