AlexanderKaraberov closed pull request #1162: Fix: Various small fixes URL: https://github.com/apache/couchdb/pull/1162
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl index acd4fda781..4e07d6e34e 100644 --- a/src/couch/src/couch_file.erl +++ b/src/couch/src/couch_file.erl @@ -213,8 +213,12 @@ truncate(Fd, Pos) -> %%---------------------------------------------------------------------- sync(Filepath) when is_list(Filepath) -> - {ok, Fd} = file:open(Filepath, [append, raw]), - try ok = file:sync(Fd) after ok = file:close(Fd) end; + case file:open(Filepath, [append, raw]) of + {ok, Fd} -> + try ok = file:sync(Fd) after ok = file:close(Fd) end; + {error, Reason} -> + throw({error, Reason}) + end; sync(Fd) -> gen_server:call(Fd, sync, infinity). @@ -388,23 +392,27 @@ init({Filepath, Options, ReturnPid, Ref}) -> erlang:send_after(?INITIAL_WAIT, self(), maybe_close), {ok, #file{fd=Fd, is_sys=IsSys, pread_limit=Limit}} end; - Error -> - init_status_error(ReturnPid, Ref, Error) + {error, Reason} -> + init_status_error(ReturnPid, Ref, {error, Reason}) end; false -> % open in read mode first, so we don't create the file if it doesn't exist. case file:open(Filepath, [read, raw]) of {ok, Fd_Read} -> - {ok, Fd} = file:open(Filepath, OpenOptions), - %% Save Fd in process dictionary for debugging purposes - put(couch_file_fd, {Fd, Filepath}), - ok = file:close(Fd_Read), - maybe_track_open_os_files(Options), - {ok, Eof} = file:position(Fd, eof), - erlang:send_after(?INITIAL_WAIT, self(), maybe_close), - {ok, #file{fd=Fd, eof=Eof, is_sys=IsSys, pread_limit=Limit}}; - Error -> - init_status_error(ReturnPid, Ref, Error) + case file:open(Filepath, OpenOptions) of + {ok, Fd} -> + %% Save Fd in process dictionary for debugging purposes + put(couch_file_fd, {Fd, Filepath}), + ok = file:close(Fd_Read), + maybe_track_open_os_files(Options), + {ok, Eof} = file:position(Fd, eof), + erlang:send_after(?INITIAL_WAIT, self(), maybe_close), + {ok, #file{fd=Fd, eof=Eof, is_sys=IsSys, pread_limit=Limit}}; + {error, Reason} -> + init_status_error(ReturnPid, Ref, {error, Reason}) + end; + {error, Reason} -> + init_status_error(ReturnPid, Ref, {error, Reason}) end end. diff --git a/src/couch/src/couch_query_servers.erl b/src/couch/src/couch_query_servers.erl index 4928eea32d..05c4c2327e 100644 --- a/src/couch/src/couch_query_servers.erl +++ b/src/couch/src/couch_query_servers.erl @@ -324,7 +324,7 @@ validate_doc_update(DDoc, EditDoc, DiskDoc, Ctx, SecObj) -> couch_stats:increment_counter([couchdb, query_server, vdu_rejects], 1) end, case Resp of - 1 -> + RespCode when is_atom(RespCode); is_number(RespCode) -> ok; {[{<<"forbidden">>, Message}]} -> throw({forbidden, Message}); diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl index bc6686b8ad..e578fe71cf 100644 --- a/src/couch_mrview/src/couch_mrview_util.erl +++ b/src/couch_mrview/src/couch_mrview_util.erl @@ -800,7 +800,8 @@ reduced_external_size(Tree) -> case couch_btree:full_reduce(Tree) of {ok, {_, _, Size}} -> Size; % return 0 for versions of the reduce function without Size - {ok, {_, _}} -> 0 + {ok, {_, _}} -> 0; + _ -> 0 end. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services