commit b32f73dd2bdcca2480a364e7cd43ac738648bc87
parent 427b70ac8cf1adb1439579500091234d28df1f1a
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date: Tue, 25 May 2010 20:18:21 -0700
make sup-dump compatibility independent of index version
Diffstat:
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/bin/sup-dump b/bin/sup-dump
@@ -15,8 +15,6 @@ later use sup-sync --restored --restore <filename> to recover the index.
This tool is primarily useful in the event that a Sup upgrade breaks index
format compatibility.
-This sup-dump supports index versions 0 through 4.
-
Usage:
sup-dump > <filename>
sup-dump | bzip2 > <filename> # even better
@@ -24,15 +22,15 @@ EOS
end
xapian = Xapian::Database.new File.join(BASE_DIR, 'xapian')
-db_version = xapian.get_metadata 'version'
-db_version = '0' if db_version.empty?
+version = xapian.get_metadata 'rescue-version'
+version = '0' if version.empty?
-case db_version
-when '0', '1', '2', '3', '4'
+case version
+when '0'
xapian.postlist('Kmail').each do |x|
entry = Marshal.load(xapian.document(x.docid).data)
puts "#{entry[:message_id]} (#{entry[:labels].sort_by { |l| l.to_s } * ' '})"
end
else
- abort "unknown index version #{db_version.inspect}"
+ abort "this sup-dump version doesn't understand your index"
end
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -114,6 +114,7 @@ EOS
else
@xapian = Xapian::WritableDatabase.new(path, Xapian::DB_CREATE)
@xapian.set_metadata 'version', INDEX_VERSION
+ @xapian.set_metadata 'rescue-version', '0'
end
@enquire = Xapian::Enquire.new @xapian
@enquire.weighting_scheme = Xapian::BoolWeight.new