[Groonga-commit] droonga/droonga-engine at 4115072 [master] Fix a bug that database migration raises exception

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Nov 6 00:06:34 JST 2014


Kouhei Sutou	2014-11-06 00:06:34 +0900 (Thu, 06 Nov 2014)

  New Revision: 4115072c5f8a13de42e368b14c39ad523513f447
  https://github.com/droonga/droonga-engine/commit/4115072c5f8a13de42e368b14c39ad523513f447

  Message:
    Fix a bug that database migration raises exception
    
    It means that we couldn't open old database with new droonga-engine. :<

  Modified files:
    lib/droonga/catalog/version2.rb

  Modified: lib/droonga/catalog/version2.rb (+10 -7)
===================================================================
--- lib/droonga/catalog/version2.rb    2014-11-05 17:30:04 +0900 (56aa025)
+++ lib/droonga/catalog/version2.rb    2014-11-06 00:06:34 +0900 (c1dd8b0)
@@ -46,8 +46,7 @@ module Droonga
               if volume_address.node == node
                 path = File.join([device, Path.databases.basename.to_s, volume_address.name, "db"])
                 path = Pathname(path).expand_path(base_path)
-                migrate_database_location(path, :device => device,
-                                                :name   => volume_address.name)
+                migrate_database_location(device, volume_address.name)
                 options = {
                   :dataset => dataset_name,
                   :database => path.to_s,
@@ -87,11 +86,15 @@ module Droonga
         nodes.sort.uniq
       end
 
-      def migrate_database_location(path, params)
-        old_path = File.join([params[:device], params[:name], "db"])
-        old_path = Pathname(old_path).expand_path(base_path)
-        if old_path.exist? and not path.exist?
-          FileUtils.move(old_path.to_s, path.to_s)
+      def migrate_database_location(device, name)
+        common_base_path = Pathname(base_path) + device
+        old_db_dir_path = common_base_path + name
+        old_db_path = old_db_dir_path + "db"
+        current_db_dir_path = common_base_path + Path.databases.basename + name
+        current_db_path = current_db_dir_path + "db"
+        if old_db_path.exist? and not current_db_path.exist?
+          FileUtils.mkdir_p(current_db_dir_path.parent)
+          FileUtils.move(old_db_dir_path, current_db_dir_path)
         end
       end
     end
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index