[Groonga-commit] groonga/groonga at cfcc027 [master] Remove system plugins dir from plugin path

Back to archive index

Kouhei Sutou null+****@clear*****
Fri May 24 11:16:50 JST 2013


Kouhei Sutou	2013-05-24 11:16:50 +0900 (Fri, 24 May 2013)

  New Revision: cfcc027bc6e9b8353aaef7a5b1dbd1a90045d0b0
  https://github.com/groonga/groonga/commit/cfcc027bc6e9b8353aaef7a5b1dbd1a90045d0b0

  Message:
    Remove system plugins dir from plugin path
    
    It improvese database portability. You can work the same database that
    uses plugin after moving database path.

  Modified files:
    lib/db.c
    lib/plugin.c

  Modified: lib/db.c (+1 -1)
===================================================================
--- lib/db.c    2013-05-23 14:37:10 +0900 (95f0687)
+++ lib/db.c    2013-05-24 11:16:50 +0900 (e84f0a9)
@@ -7092,7 +7092,7 @@ grn_ctx_at(grn_ctx *ctx, grn_id id)
                   break;
                 case GRN_PROC :
                   GET_PATH(spec, buffer, s, id);
-                  grn_plugin_register_by_path(ctx, buffer);
+                  grn_plugin_register(ctx, buffer);
                   break;
                 case GRN_EXPR :
                   {

  Modified: lib/plugin.c (+17 -1)
===================================================================
--- lib/plugin.c    2013-05-23 14:37:10 +0900 (369ccba)
+++ lib/plugin.c    2013-05-24 11:16:50 +0900 (d202517)
@@ -59,8 +59,24 @@ grn_plugin_get(grn_ctx *ctx, const char *filename)
 const char *
 grn_plugin_path(grn_ctx *ctx, grn_id id)
 {
+  const char *path;
   uint32_t key_size;
-  return _grn_hash_key(ctx, grn_plugins, id, &key_size);
+  const char *system_plugins_dir;
+  size_t system_plugins_dir_size;
+
+  path = _grn_hash_key(ctx, grn_plugins, id, &key_size);
+  system_plugins_dir = grn_plugin_get_system_plugins_dir();
+  system_plugins_dir_size = strlen(system_plugins_dir);
+  if (strncmp(system_plugins_dir, path, system_plugins_dir_size) == 0) {
+    const char *plugin_name = path + system_plugins_dir_size;
+    while (plugin_name[0] == '/') {
+      plugin_name++;
+    }
+    /* TODO: remove suffix too? */
+    return plugin_name;
+  } else {
+    return path;
+  }
 }
 
 #define GRN_PLUGIN_FUNC_PREFIX "grn_plugin_impl_"
-------------- next part --------------
HTML����������������������������...
下载 



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