In playing with offline IMAP and Maildir sources (much faster than a native IMAP
source and it can be used offline!), I noticed an odd bug.
If there is only one message in a Maildir source, neither sup not
sup-sync can see this message. Adding another message makes both
visible messages visible.
--- here begins speculation ---
I *THINK* that this has to do with the definitions Source.start_offset
and Source.end_offset. As I understand it, they should define a range
of message ids [start_offset, end_offset).
Now, when start_offset = end_offset--as is the case when there is only
one message, bad things happen. As I understand the math:
(a,a) = {}
[a,a) = {} *our case
(a,a] = {}
[a,a] = {a.
Changing maildir.rb:126 from:
@ids.last
to
@ids.last + 1
appears to have fixed the problem without ill-effect.
Simple inspection of imap.rp leads be to believe that it will have the
same problem.
A mbox source will have the same problem iff the mbox is empty.
--- here ends speculation ---
--
Christopher Warrington <chrisw at rice.edu>
Christopher Warrington
2008-Mar-03 08:00 UTC
[sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb
The end_offset reported by imap and maildir sources was incorrect if there was
only one message in the source. Since end_offset is exclusive, we must add one
to
the last known id to get include all valid message ids in the range.
---
lib/sup/imap.rb | 2 +-
lib/sup/maildir.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb
index e785597..1d36976 100644
--- a/lib/sup/imap.rb
+++ b/lib/sup/imap.rb
@@ -176,7 +176,7 @@ class IMAP < Source
def end_offset
unsynchronized_scan_mailbox
- @ids.last
+ @ids.last + 1
end
synchronized :end_offset
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
index 5c9600d..584e657 100644
--- a/lib/sup/maildir.rb
+++ b/lib/sup/maildir.rb
@@ -123,7 +123,7 @@ class Maildir < Source
def end_offset
scan_mailbox :rescan => true
- @ids.last
+ @ids.last + 1
end
def pct_done; 100.0 * (@ids.index(cur_offset) || 0).to_f / (@ids.length -
1).to_f; end
--
1.5.3.7
William Morgan
2008-Mar-26 16:04 UTC
[sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb
Reformatted excerpts from Christopher Warrington''s message of 2008-03-03:> The end_offset reported by imap and maildir sources was incorrect if > there was only one message in the source. Since end_offset is > exclusive, we must add one to the last known id to get include all > valid message ids in the range.Precisely so. Applied. Thanks! -- William <wmorgan-sup at masanjin.net>
Grant Hollingworth
2008-Apr-03 16:35 UTC
[sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb
* William Morgan [Wed Mar 26 12:04:10 -0400 2008]:> Precisely so. Applied. Thanks!This breaks Source#done?, so every poll the last message of each source gets reloaded. The state gets fixed from the index but it''s still ugly.
William Morgan
2008-Apr-04 17:48 UTC
[sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb
Reformatted excerpts from Grant Hollingworth''s message of 2008-04-03:> This breaks Source#done?, so every poll the last message of each > source gets reloaded. The state gets fixed from the index but it''s > still ugly.Gah. I will take a look. -- William <wmorgan-sup at masanjin.net>