+
+ def upgrade_data2
+ if File.exist?("#{@bot.botclass}/plugin_registry.db")
+ Dir.mkdir("#{@bot.botclass}/registry") unless File.exist?("#{@bot.botclass}/registry")
+ env = BDB::Env.open("#{@bot.botclass}", BDB::INIT_TRANSACTION | BDB::CREATE | BDB::RECOVER)
+ dbs = Hash.new
+ puts "upgrading previous (rbot 0.9.9 or earlier) plugin registry to new split format"
+ old = BDB::CIBtree.open("#{@bot.botclass}/plugin_registry.db", nil,
+ "r+", 0600, "env" => env)
+ old.each {|k,v|
+ prefix,key = k.split("/", 2)
+ prefix.downcase!
+ unless dbs.has_key?(prefix)
+ puts "creating db #{@bot.botclass}/registry/#{prefix}.db"
+ dbs[prefix] = BDB::CIBtree.open("#{@bot.botclass}/registry/#{prefix}.db",
+ nil, BDB::CREATE | BDB::EXCL,
+ 0600, "env" => env)
+
+ end
+ dbs[prefix][key] = v
+ }
+ old.close
+ File.rename("#{@bot.botclass}/plugin_registry.db", "#{@bot.botclass}/plugin_registry.db.old")
+ dbs.each {|k,v|
+ puts "closing db #{k}"
+ v.close
+ }
+ env.close
+ end
+ end