summaryrefslogtreecommitdiff
path: root/lib/rbot/registry.rb
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2006-02-10 18:52:56 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2006-02-10 18:52:56 +0000
commit44688c76d937c2dade10aaa7bb7e70e508b33684 (patch)
tree30d0751ea9feab5c039f64e60e2811e2821a11fb /lib/rbot/registry.rb
parent2ed83d89e5fad7d0bed1003fdc60b538a4187162 (diff)
use a db env for the databases to avoid some corruption problems (I hope)
Diffstat (limited to 'lib/rbot/registry.rb')
-rw-r--r--lib/rbot/registry.rb25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/rbot/registry.rb b/lib/rbot/registry.rb
index 6388c91d..536305d3 100644
--- a/lib/rbot/registry.rb
+++ b/lib/rbot/registry.rb
@@ -18,12 +18,10 @@ module Irc
if File.exist?("#{@bot.botclass}/registry.db")
puts "upgrading old-style (rbot 0.9.5 or earlier) plugin registry to new format"
old = BDB::Hash.open("#{@bot.botclass}/registry.db", nil,
- "r+", 0600, "set_pagesize" => 1024,
- "set_cachesize" => [0, 32 * 1024, 0])
+ "r+", 0600)
new = BDB::CIBtree.open("#{@bot.botclass}/plugin_registry.db", nil,
- BDB::CREATE | BDB::EXCL | BDB::TRUNCATE,
- 0600, "set_pagesize" => 1024,
- "set_cachesize" => [0, 32 * 1024, 0])
+ BDB::CREATE | BDB::EXCL,
+ 0600)
old.each {|k,v|
new[k] = v
}
@@ -35,21 +33,21 @@ module Irc
def upgrade_data2
if File.exist?("#{@bot.botclass}/plugin_registry.db")
- Dir.mkdir("#{@bot.botclass}/registry")
+ 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, "set_pagesize" => 1024,
- "set_cachesize" => [0, 32 * 1024, 0])
+ "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 | BDB::TRUNCATE,
- 0600, "set_pagesize" => 1024,
- "set_cachesize" => [0, 32 * 1024, 0])
+ nil, BDB::CREATE | BDB::EXCL,
+ 0600, "env" => env)
+
end
dbs[prefix][key] = v
}
@@ -59,6 +57,7 @@ module Irc
puts "closing db #{k}"
v.close
}
+ env.close
end
end
end
@@ -276,10 +275,6 @@ module Irc
end
alias size length
- def flush
- @registry.flush
- end
-
end
end