upgrade_data2 (Irc::Bot::Registry)

    # File lib/rbot/registry.rb, line 35
        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)# | BDB::TXN_NOSYNC)
            dbs = Hash.new
            log _("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!
              # subregistries were split with a +, now they are in separate folders
              if prefix.gsub!(/\+/, "/")
                # Ok, this code needs to be put in the db opening routines
                dirs = File.dirname("#{@bot.botclass}/registry/#{prefix}.db").split("/")
                dirs.length.times { |i|
                  dir = dirs[0,i+1].join("/")+"/"
                  unless File.exist?(dir)
                    log _("creating subregistry directory #{dir}")
                    Dir.mkdir(dir)
                  end
                }
              end
              unless dbs.has_key?(prefix)
                log _("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|
              log _("closing db #{k}")
              v.close
            }
            env.close
          end
        end