couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [couchdb] 01/04: Avoid file_server_2 for existance tests
Date Wed, 19 Sep 2018 15:51:06 GMT
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch couch-server-ets-lru
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit a1bd5de2023b2cf6d944dc1fa46ac26446d8dad4
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
AuthorDate: Tue Sep 18 15:38:39 2018 -0500

    Avoid file_server_2 for existance tests
    
    Its not uncommon to have file_server_2 behaving poorly so we'll avoid it
    when there are calls that are made often.
---
 src/couch/src/couch_bt_engine.erl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl
index 6d858ed..5e3e7f2 100644
--- a/src/couch/src/couch_bt_engine.erl
+++ b/src/couch/src/couch_bt_engine.erl
@@ -108,16 +108,17 @@
 ]).
 
 
+-include_lib("kernel/include/file.hrl").
 -include_lib("couch/include/couch_db.hrl").
 -include("couch_bt_engine.hrl").
 
 
 exists(FilePath) ->
-    case filelib:is_file(FilePath) of
+    case is_file(FilePath) of
         true ->
             true;
         false ->
-            filelib:is_file(FilePath ++ ".compact")
+            is_file(FilePath ++ ".compact")
     end.
 
 
@@ -1140,3 +1141,10 @@ finish_compaction_int(#st{} = OldSt, #st{} = NewSt1) ->
     {ok, NewSt2#st{
         filepath = FilePath
     }, undefined}.
+
+
+is_file(Path) ->
+    case file:read_file_info(Path, [raw]) of
+        {ok, #file_info{type = regular}} -> true;
+        _ -> false
+    end.


Mime
View raw message