]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
markov: be more robust about flaky dbs
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 31 Aug 2012 19:04:47 +0000 (21:04 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 31 Aug 2012 19:04:47 +0000 (21:04 +0200)
Due to historical bugs, some database entries may have ended up being
serialized as strings. Recover from this by making them into arrays.

data/rbot/plugins/markov.rb

index 621935c60a87225f9631fe4045f0b722f3ae5bb2..eb9294e2b141bb00e75f17fbba183df3fb9ec6ca 100755 (executable)
@@ -183,6 +183,9 @@ class MarkovPlugin < Plugin
     @upgrade_queue.push nil
 
     @upgrade_thread = Thread.new do
+      @registry.recovery = Proc.new { |val|
+        return [val]
+      }
       logfile = File.open(@bot.path('markov-conversion.log'), 'a')
       logfile.puts "=== conversion thread started #{Time.now} ==="
       while k = @upgrade_queue.pop
@@ -199,6 +202,7 @@ class MarkovPlugin < Plugin
       end
       logfile.puts "=== conversion thread stopped #{Time.now} ==="
       logfile.close
+      @registry.recovery = nil
     end
     @upgrade_thread.priority = -1
   end