commit e6f774f3a0de2b7eae0044e5cf575cef923017c9
parent 90bc833454f62d4c7d543ade8519201071e166df
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date: Sat, 16 Jan 2010 12:03:07 -0800
trivial index format upgrade
A v2 client can read a v1 index, but a v1 client cannot read a v2 index. Once
the v2 client modifies the index the v1 client will be unable to read it. So,
make the version check match that.
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
@@ -10,7 +10,7 @@ module Redwood
# for searching due to precomputing thread membership.
class XapianIndex < BaseIndex
STEM_LANGUAGE = "english"
- INDEX_VERSION = '1'
+ INDEX_VERSION = '2'
## dates are converted to integers for xapian, and are used for document ids,
## so we must ensure they're reasonably valid. this typically only affect
@@ -37,7 +37,10 @@ EOS
@xapian = Xapian::WritableDatabase.new(path, Xapian::DB_OPEN)
db_version = @xapian.get_metadata 'version'
db_version = '0' if db_version.empty?
- if db_version != INDEX_VERSION
+ if db_version == '1'
+ info "Upgrading index format 1 to 2"
+ @xapian.set_metadata 'version', INDEX_VERSION
+ elsif db_version != INDEX_VERSION
fail "This Sup version expects a v#{INDEX_VERSION} index, but you have an existing v#{db_version} index. Please downgrade to your previous version and dump your labels before upgrading to this version (then run sup-sync --restore)."
end
else