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 2019/10/24 18:13:18 UTC
[couchdb] 02/06: Avoid file_server_2 for existance tests
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch optimize-couch-server
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 67b82fe206fa219cc692c39cb60a9871f7c9eb58
Author: Paul J. Davis <pa...@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 e3e4d0d..cd4f753 100644
--- a/src/couch/src/couch_bt_engine.erl
+++ b/src/couch/src/couch_bt_engine.erl
@@ -114,16 +114,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.
@@ -1235,3 +1236,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.