sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 81f446537366d39d41035d47ecf7a7cc2b9c3b75
parent 7749ea37e2204edae4e168b41629c50b4da15677
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Tue, 14 Oct 2008 13:10:48 -0700

fix up IMAP deletion

Diffstat:
M lib/sup/imap.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb
@@ -118,12 +118,15 @@ class IMAP < Source
     ids = [ids].flatten # accept single arguments
     unsynchronized_scan_mailbox
     imap_ids = ids.map { |i| @imap_state[i] && @imap_state[i][:id] }.compact
+    return if imap_ids.empty?
     @imap.store imap_ids, "+FLAGS", [:Deleted]
   end
   synchronized :mark_as_deleted
 
   def expunge
     @imap.expunge
+    unsynchronized_scan_mailbox true
+    true
   end
   synchronized :expunge
 
@@ -133,14 +136,15 @@ class IMAP < Source
   end
   synchronized :connect
 
-  def scan_mailbox
-    return if @last_scan && (Time.now - @last_scan) < SCAN_INTERVAL
+  def scan_mailbox force=false
+    return if !force && @last_scan && (Time.now - @last_scan) < SCAN_INTERVAL
     last_id = safely do
       @imap.examine mailbox
       @imap.responses["EXISTS"].last
     end
     @last_scan = Time.now
 
+    @ids = [] if force
     return if last_id == @ids.length
 
     range = (@ids.length + 1) .. last_id