From: marka@pobox.com (Mark Alexander)
Subject: [sup-talk] [PATCH] Bug fixes and speed improvements for maildir handling.
Date: Tue, 21 Apr 2009 08:43:44 -0700 [thread overview]
Message-ID: <a412e2a70904210843p6410e83dyabccb3dec5c9fd0a@mail.gmail.com> (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
next reply other threads:[~2009-04-21 15:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-21 15:43 Mark Alexander [this message]
2009-05-04 14:28 ` William Morgan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a412e2a70904210843p6410e83dyabccb3dec5c9fd0a@mail.gmail.com \
--to=marka@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox