summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2018-09-18 15:38:39 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2020-01-05 14:16:52 -0600
commit009e4d5ac4a45bbbe017ba9cf4349b08e52d7335 (patch)
treedefbe003288ef83d72970b0792a8f999ebbc01ae
parent36cf8936f88d8e9b519bd94aab433933691ff6ae (diff)
downloadcouchdb-009e4d5ac4a45bbbe017ba9cf4349b08e52d7335.tar.gz
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.
-rw-r--r--src/couch/src/couch_bt_engine.erl13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl
index e3e4d0d32..b659719f5 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,11 @@ 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;
+ {ok, #file_info{type = directory}} -> true;
+ _ -> false
+ end.