]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/registry/bdb.rb
bdb: restore errors should be logged as errors
[user/henk/code/ruby/rbot.git] / lib / rbot / registry / bdb.rb
index 5acfe4910cd331b17fe7b3b479a121c1cab24678..8410d8aced93dd9a82e9c52e39809d97b0155e8f 100644 (file)
@@ -6,7 +6,7 @@
 begin
   require 'bdb'
 rescue LoadError
-  fatal "rbot couldn't load the bdb module, perhaps you need to install it? try: http://www.ruby-lang.org/en/raa-list.rhtml?name=bdb"
+  fatal "rbot couldn't load the bdb module, perhaps you need to install it? try http://www.ruby-lang.org/en/raa-list.rhtml?name=bdb or http://github.com/knu/ruby-bdb"
 rescue Exception => e
   fatal "rbot couldn't load the bdb module: #{e.pretty_inspect}"
 end
@@ -36,7 +36,7 @@ module BDB
   class CIBtree < Btree
     def bdb_bt_compare(a, b)
       if a == nil || b == nil
-        warning "CIBTree: comparing #{a.inspect} (#{self[a].inspect}) with #{b.inspect} (#{self[b].inspect})"
+        warning "CIBTree: comparing key #{a.inspect} with #{b.inspect}"
       end
       (a||'').downcase <=> (b||'').downcase
     end
@@ -146,6 +146,10 @@ module Irc
     end
 
     def DBTree.cleanup_logs()
+      if @@env.nil?
+        debug "No BDB environment, skipping checkpoint"
+        return
+      end
       begin
         debug "DBTree: checkpointing ..."
         @@env.checkpoint
@@ -166,6 +170,10 @@ module Irc
     end
 
     def DBTree.stats()
+      if @@env.nil?
+        debug "No BDB environment, no stats"
+        return
+      end
       begin
         debug "General stats:"
         debug @@env.stat
@@ -181,6 +189,10 @@ module Irc
     end
 
     def DBTree.cleanup_env()
+      if @@env.nil?
+        debug "No BDB environment, skipping cleanup"
+        return
+      end
       begin
         debug "DBTree: checking transactions ..."
         has_active_txn = @@env.txn_stat["st_nactive"] > 0
@@ -365,6 +377,7 @@ class Bot
       # debug "closing registry #{registry}"
       return if !@registry
       registry.close
+      @registry = nil
     end
 
     # convert value to string form for storing in the registry
@@ -396,7 +409,7 @@ class Bot
             return @recovery.call(val)
           rescue Exception => ee
             error _("marshal recovery failed, trying default")
-            debug ee
+            error ee
           end
         end
         return default