]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
TokyoCabinet: 0.9.5-to-0.9.9 must use BDB only
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 23 Sep 2010 20:20:57 +0000 (22:20 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 23 Sep 2010 20:20:57 +0000 (22:20 +0200)
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

index 8279f63a7fea25193f64b0ebe571618ba7112918..2c1198ecb522d1e781f21000fc74717fda8a8d1d 100644 (file)
@@ -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")