You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/05/10 16:03:11 UTC

[couchdb] 05/05: Add couch_server:get_possible_engines/3

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch COUCHDB-3287-pluggable-storage-engines
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 30d29f4c83ef3b92928caa9d33c57dc5f290190f
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed May 10 11:02:57 2017 -0500

    Add couch_server:get_possible_engines/3
---
 src/couch/src/couch_server.erl | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl
index 650b961..60ecc5e 100644
--- a/src/couch/src/couch_server.erl
+++ b/src/couch/src/couch_server.erl
@@ -121,15 +121,7 @@ delete(DbName, Options) ->
 exists(DbName) ->
     RootDir = config:get("couchdb", "database_dir", "."),
     Engines = get_configured_engines(),
-    Possible = lists:foldl(fun({Extension, Engine}, Acc) ->
-        Path = make_filepath(RootDir, DbName, Extension),
-        case couch_db_engine:exists(Engine, Path) of
-            true ->
-                [{Engine, Path} | Acc];
-            false ->
-                Acc
-        end
-    end, [], Engines),
+    Possible = get_possible_engines(DbName, RootDir, Engines),
     Possible /= [].
 
 
@@ -608,15 +600,7 @@ get_engine(Server, DbName) ->
         root_dir = RootDir,
         engines = Engines
     } = Server,
-    Possible = lists:foldl(fun({Extension, Engine}, Acc) ->
-        Path = make_filepath(RootDir, DbName, Extension),
-        case couch_db_engine:exists(Engine, Path) of
-            true ->
-                [{Engine, Path} | Acc];
-            false ->
-                Acc
-        end
-    end, [], Engines),
+    Possible = get_possible_engines(DbName, RootDir, Engines),
     case Possible of
         [] ->
             get_default_engine(Server, DbName);
@@ -627,6 +611,18 @@ get_engine(Server, DbName) ->
     end.
 
 
+get_possible_engines(DbName, RootDir, Engines) ->
+    lists:foldl(fun({Extension, Engine}, Acc) ->
+        Path = make_filepath(RootDir, DbName, Extension),
+        case couch_db_engine:exists(Engine, Path) of
+            true ->
+                [{Engine, Path} | Acc];
+            false ->
+                Acc
+        end
+    end, [], Engines),
+
+
 get_default_engine(Server, DbName) ->
     #server{
         root_dir = RootDir,

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.