sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 970fd2006b80dc6dbd0e5df077150cf4b589cb32
parent 6339e161040978e13358753139c9e72023c454ee
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Fri, 19 Mar 2010 13:40:57 -0700

backwards compatibility with older index formats

Diffstat:
M lib/sup/index.rb | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -519,7 +519,7 @@ EOS
 
   def get_entry id
     return unless doc = find_doc(id)
-    Marshal.load doc.data
+    doc.entry
   end
 
   def thread_killed? thread_id
@@ -661,7 +661,7 @@ EOS
   def index_message_locations doc, entry, old_entry
     old_entry[:locations].map { |x| x[0] }.uniq.each { |x| doc.remove_term mkterm(:source_id, x) } if old_entry
     entry[:locations].map { |x| x[0] }.uniq.each { |x| doc.add_term mkterm(:source_id, x) }
-    old_entry[:locations].each { |x| doc.remove_term mkterm(:location, *x) } if old_entry
+    old_entry[:locations].each { |x| (doc.remove_term mkterm(:location, *x) rescue nil) } if old_entry
     entry[:locations].each { |x| doc.add_term mkterm(:location, *x) }
   end
 
@@ -743,7 +743,13 @@ end
 
 class Xapian::Document
   def entry
-    Marshal.load data
+    entry = Marshal.load data
+    if entry[:source_id]
+      entry[:locations] = [[entry[:source_id], entry[:source_info]]]
+      entry.delete :source_id
+      entry.delete :source_info
+    end
+    entry
   end
 
   def entry=(x)