* [sup-talk] Maildir source with one message
@ 2008-03-03 7:07 Christopher Warrington
2008-03-03 8:00 ` [sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb Christopher Warrington
0 siblings, 1 reply; 5+ messages in thread
From: Christopher Warrington @ 2008-03-03 7:07 UTC (permalink / raw)
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb
2008-03-03 7:07 [sup-talk] Maildir source with one message Christopher Warrington
@ 2008-03-03 8:00 ` Christopher Warrington
2008-03-26 16:04 ` William Morgan
0 siblings, 1 reply; 5+ messages in thread
From: Christopher Warrington @ 2008-03-03 8:00 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb
2008-03-03 8:00 ` [sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb Christopher Warrington
@ 2008-03-26 16:04 ` William Morgan
2008-04-03 16:35 ` Grant Hollingworth
0 siblings, 1 reply; 5+ messages in thread
From: William Morgan @ 2008-03-26 16:04 UTC (permalink / raw)
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb
2008-03-26 16:04 ` William Morgan
@ 2008-04-03 16:35 ` Grant Hollingworth
2008-04-04 17:48 ` William Morgan
0 siblings, 1 reply; 5+ messages in thread
From: Grant Hollingworth @ 2008-04-03 16:35 UTC (permalink / raw)
* 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb
2008-04-03 16:35 ` Grant Hollingworth
@ 2008-04-04 17:48 ` William Morgan
0 siblings, 0 replies; 5+ messages in thread
From: William Morgan @ 2008-04-04 17:48 UTC (permalink / raw)
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-04-04 17:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-03 7:07 [sup-talk] Maildir source with one message Christopher Warrington
2008-03-03 8:00 ` [sup-talk] [PATCH] fixed off-by-one error in imap.rb and maildir.rb Christopher Warrington
2008-03-26 16:04 ` William Morgan
2008-04-03 16:35 ` Grant Hollingworth
2008-04-04 17:48 ` William Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox