[Groonga-commit] groonga/groonga at 2ede591 [master] dat: enable truncate for temporary dat tries

Back to archive index

Susumu Yata null+****@clear*****
Tue Jan 31 12:16:22 JST 2017


Susumu Yata	2017-01-31 12:16:22 +0900 (Tue, 31 Jan 2017)

  New Revision: 2ede591f1ec19be4a4e03d3006985196c5a307f3
  https://github.com/groonga/groonga/commit/2ede591f1ec19be4a4e03d3006985196c5a307f3

  Message:
    dat: enable truncate for temporary dat tries
    
    GitHub: fix #623
    
    Reported by Naoya Murakami. Thanks!!!

  Modified files:
    lib/dat.cpp

  Modified: lib/dat.cpp (+20 -8)
===================================================================
--- lib/dat.cpp    2017-01-31 12:12:09 +0900 (db6c0a6)
+++ lib/dat.cpp    2017-01-31 12:16:22 +0900 (c4cd90a)
@@ -194,14 +194,26 @@ grn_dat_open_trie_if_needed(grn_ctx *ctx, grn_dat *dat)
     return false;
   }
 
-  try {
-    new_trie->open(trie_path);
-  } catch (const grn::dat::Exception &ex) {
-    ERR(grn_dat_translate_error_code(ex.code()),
-        "grn::dat::Trie::open failed: %s",
-        ex.what());
-    delete new_trie;
-    return false;
+  if (trie_path[0] == '\0') {
+    try {
+      new_trie->create(trie_path);
+    } catch (const grn::dat::Exception &ex) {
+      ERR(grn_dat_translate_error_code(ex.code()),
+          "grn::dat::Trie::create failed: %s",
+          ex.what());
+      delete new_trie;
+      return false;
+    }
+  } else {
+    try {
+      new_trie->open(trie_path);
+    } catch (const grn::dat::Exception &ex) {
+      ERR(grn_dat_translate_error_code(ex.code()),
+          "grn::dat::Trie::open failed: %s",
+          ex.what());
+      delete new_trie;
+      return false;
+    }
   }
 
   dat->old_trie = trie;
-------------- next part --------------
HTML����������������������������...
Download 



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