sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 7a1e08be68e295ce6517984a4195b2afcbe64211
parent eb59f86a346340b16a0b13f93d2c7245e40b8f55
Author: Johannes Larsen <mail@johslarsen.net>
Date:   Thu, 28 May 2015 23:49:32 +0200

Do not create drafts IDs that will not be polled

Polling DraftLoader will only add messages that have an ID larger than
any previous polled messages, so instead of reusing the ID-space only
create IDs that are larger than any previous added ID.

Reusing the ID-space causes a race-condition where a new draft can be
given an ID that was used by some discarded draft, so that polling
DraftLoader will ignore the newly created draft because it thinks that
this message have already been loaded.

It should be noted that DraftLoader is lazily initialized, so creating
draft IDs will reuse the ID-space as long as these messages has not yet
been polled, but this is not problematic because this part of the
ID-space will be added during the next poll.

Signed-off-by: Johannes Larsen 

Diffstat:
M lib/sup/draft.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/sup/draft.rb b/lib/sup/draft.rb
@@ -61,7 +61,7 @@ class DraftLoader < Source
   end
 
   def gen_offset
-    i = 0
+    i = @cur_offset
     while File.exist? fn_for_offset(i)
       i += 1
     end