summaryrefslogtreecommitdiff
path: root/lib/rbot/registry
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2010-09-23 22:20:57 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2010-09-23 22:20:57 +0200
commitc9529b17e30818c145a4f00c70ad31e823ab7561 (patch)
tree6f71923d03e436e15401efe48134c1205c123a46 /lib/rbot/registry
parentd751305992437967621bdb9121376ea5c1753bcf (diff)
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.)
Diffstat (limited to 'lib/rbot/registry')
-rw-r--r--lib/rbot/registry/tc.rb10
1 files 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")