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.)
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")