Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] Bug fixes and speed improvements for maildir handling.
@ 2009-04-21 15:43 Mark Alexander
  2009-05-04 14:28 ` William Morgan
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Alexander @ 2009-04-21 15:43 UTC (permalink / raw)


---
 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


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

* [sup-talk] [PATCH] Bug fixes and speed improvements for maildir handling.
  2009-04-21 15:43 [sup-talk] [PATCH] Bug fixes and speed improvements for maildir handling Mark Alexander
@ 2009-05-04 14:28 ` William Morgan
  0 siblings, 0 replies; 2+ messages in thread
From: William Morgan @ 2009-05-04 14:28 UTC (permalink / raw)


Reformatted excerpts from Mark Alexander's message of 2009-04-21:
> ---
>  lib/sup/maildir.rb |   10 +++++++---
>  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>


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

end of thread, other threads:[~2009-05-04 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-21 15:43 [sup-talk] [PATCH] Bug fixes and speed improvements for maildir handling Mark Alexander
2009-05-04 14:28 ` William Morgan

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