diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2011-07-11 17:26:00 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2011-07-11 17:26:00 +0200 |
commit | 33c582acdb8c57f302145fc3dc01a1bf2d7c8478 (patch) | |
tree | 604d2491c55e5090ec8518e1198d4befa89d4615 /lib/rbot/registry/tc.rb | |
parent | 2a3bc07d139593f1f57e23cfbd08602d29a8b26c (diff) |
Fix TC db close on cleanup
When closing the TC db on cleanup, we didn't remove it from the
environment. Override the #close() method to achieve that.
Diffstat (limited to 'lib/rbot/registry/tc.rb')
-rw-r--r-- | lib/rbot/registry/tc.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/rbot/registry/tc.rb b/lib/rbot/registry/tc.rb index 4477c115..8ffd3e40 100644 --- a/lib/rbot/registry/tc.rb +++ b/lib/rbot/registry/tc.rb @@ -117,15 +117,19 @@ module Irc if absfilename && File.exist?(key) # db already exists, use it @db = DBTree.open_db(key) + @fname = key.dup elsif absfilename # create empty db @db = DBTree.create_db(key) + @fname = key.dup elsif File.exist? relfilename # db already exists, use it @db = DBTree.open_db relfilename + @fname = relfilename.dup else # create empty db @db = DBTree.create_db relfilename + @fname = relfilename.dup end oldbasename = (absfilename ? key : relfilename).gsub(/\.tdb$/, ".db") if File.exists? oldbasename and defined? BDB @@ -155,6 +159,14 @@ module Irc @@bot_registries.clear end + def close + db = @@bot_registries.delete(@fname) + if db != @db + error "We think we have #{@db} from #{@fname}, TC pseudo-env gives us #{db}" + end + @db.close + end + def DBTree.create_db(name) debug "DBTree: creating empty db #{name}" if @@bot_registries.key? name |