[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sup-devel] [PATCH 4/4] 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.
---
lib/sup/xapian_index.rb | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
index eefd492..464cee1 100644
--- a/lib/sup/xapian_index.rb
+++ b/lib/sup/xapian_index.rb
@@ -8,7 +8,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
@@ -35,7 +35,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
--
1.6.5.2
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel