]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
[registry] migrate tc directory name to registry_tc
authorMatthias Hecker <apoc@sixserv.org>
Wed, 5 Mar 2014 13:05:03 +0000 (14:05 +0100)
committerMatthias Hecker <apoc@sixserv.org>
Wed, 5 Mar 2014 13:05:03 +0000 (14:05 +0100)
lib/rbot/ircbot.rb
lib/rbot/registry.rb

index b954e3b5c63c2306b0668f03a3a947c3fef0321b..8b827f15fb59484c88c54df7e0523cd88a51638a 100644 (file)
@@ -504,6 +504,7 @@ class Bot
     end
 
     @registry_factory = Registry.new @config['core.db']
+    @registry_factory.migrate_registry_folder(path)
 
     @logfile = @config['log.file']
     if @logfile.class!=String || @logfile.empty?
index 799e69ee4f0a72d9876b1257842dcd41b3915e84..0eefc9da2155f1f1ae83a2d211e87514ea97c818 100644 (file)
@@ -83,6 +83,18 @@ class Registry
     @@formats ||= Registry.new.discover
   end
 
+  # Will detect tokyocabinet registry location: ~/.rbot/registry/*.tdb
+  #  and move it to its new location ~/.rbot/registry_tc/*.tdb
+  def migrate_registry_folder(path)
+    old_name = File.join(path, 'registry')
+    new_name = File.join(path, 'registry_tc')
+    if @format == 'tc' and File.exists?(old_name) and
+        not File.exists?(new_name) and
+        not Dir.glob(File.join(old_name, '*.tdb')).empty?
+      File.rename(old_name, new_name)
+    end
+  end
+
   # Abstract database accessor (a hash-like interface).
   class AbstractAccessor