From c9529b17e30818c145a4f00c70ad31e823ab7561 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 23 Sep 2010 22:20:57 +0200 Subject: [PATCH] TokyoCabinet: 0.9.5-to-0.9.9 must use BDB only When upgrading from 0.9.5 data, write the 0.9.9-style regisitry using BDB still rather than trying to use TokyoCabinet already. This makes sure that the next step (0.9.9 to modern times) works correctly. (Moreover, the existing BDB-to-TC attempt wouldn't have worked anyway due to wrong var names. I doubt anybody will ever hit this path and notice though.) --- lib/rbot/registry/tc.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/rbot/registry/tc.rb b/lib/rbot/registry/tc.rb index 8279f63a..2c1198ec 100644 --- a/lib/rbot/registry/tc.rb +++ b/lib/rbot/registry/tc.rb @@ -197,12 +197,10 @@ class Bot if File.exist?(oldreg) log _("upgrading old-style (rbot 0.9.5 or earlier) plugin registry to new format") old = ::BDB::Hash.open(oldreg, nil, "r+", 0600) - new = TokyoCabinet::CIBDB.new - new.open(name, TokyoCabinet::CIBDB::OREADER | TokyoCabinet::CIBDB::OCREAT | TokyoCabinet::CIBDB::OWRITER) - old.each_key do |k| - new.outlist k - new.putlist k, (old.duplicates(k, false)) - end + new = ::BDB::CIBtree.open(newreg, nil, ::BDB::CREATE | ::BDB::EXCL, 0600) + old.each {|k,v| + new[k] = v + } old.close new.close File.rename(oldreg, oldreg + ".old") -- 2.39.2