summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/couchdb/couch_config_writer.erl13
-rw-r--r--src/couchdb/couch_httpd_db.erl17
-rw-r--r--src/couchdb/couch_key_tree.erl8
3 files changed, 11 insertions, 27 deletions
diff --git a/src/couchdb/couch_config_writer.erl b/src/couchdb/couch_config_writer.erl
index fd4a0215..e47b9052 100644
--- a/src/couchdb/couch_config_writer.erl
+++ b/src/couchdb/couch_config_writer.erl
@@ -54,11 +54,8 @@ save_to_file({{Section, Option}, Value}, File) ->
_ ->
NewFileContents2
end,
-
- % do the save, close the config file and get out
- save_file(File, NewFileContents),
- file:close(Stream),
-
+
+ ok = file:write_file(File, list_to_binary(NewFileContents)),
ok.
%% @doc Iterates over the lines of an ini file and replaces or adds a new
@@ -164,9 +161,3 @@ parse_variable(Line, Option, Value) ->
{match, _Start, _Length} ->
Option ++ " = " ++ Value
end.
-
-%% @spec save_file(File::filename(), Contents::string()) ->
-%% ok | {error, Reason::string()}
-%% @doc Writes Contents to File
-save_file(File, Contents) ->
- file:write_file(File, list_to_binary(Contents)). \ No newline at end of file
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index d1d90c63..8c692f8d 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -637,19 +637,16 @@ db_doc_req(#httpd{method='COPY'}=Req, Db, SourceDocId) ->
missing_rev -> nil;
Rev -> Rev
end,
-
{TargetDocId, TargetRevs} = parse_copy_destination_header(Req),
-
- % open revision Rev or Current
+ % open old doc
Doc = couch_doc_open(Db, SourceDocId, SourceRev, []),
% save new doc
- case couch_db:update_doc(Db, Doc#doc{id=TargetDocId, revs=TargetRevs}, []) of
- {ok, NewTargetRev} ->
- send_json(Req, 201, [{"Etag", "\"" ++ ?b2l(couch_doc:rev_to_str(NewTargetRev)) ++ "\""}],
- update_doc_result_to_json(TargetDocId, {ok, NewTargetRev}));
- Error ->
- throw(Error)
- end;
+ {ok, NewTargetRev} = couch_db:update_doc(Db,
+ Doc#doc{id=TargetDocId, revs=TargetRevs}, []),
+ % respond
+ send_json(Req, 201,
+ [{"Etag", "\"" ++ ?b2l(couch_doc:rev_to_str(NewTargetRev)) ++ "\""}],
+ update_doc_result_to_json(TargetDocId, {ok, NewTargetRev}));
db_doc_req(Req, _Db, _DocId) ->
send_method_not_allowed(Req, "DELETE,GET,HEAD,POST,PUT,COPY").
diff --git a/src/couchdb/couch_key_tree.erl b/src/couchdb/couch_key_tree.erl
index d983e20f..87313ff0 100644
--- a/src/couchdb/couch_key_tree.erl
+++ b/src/couchdb/couch_key_tree.erl
@@ -29,12 +29,8 @@ merge(A, B) ->
{Merged, HasConflicts} =
lists:foldl(
fun(InsertTree, {AccTrees, AccConflicts}) ->
- case merge_one(AccTrees, InsertTree, [], false) of
- {ok, Merged, Conflicts} ->
- {Merged, Conflicts or AccConflicts};
- no ->
- {[InsertTree | AccTrees], true}
- end
+ {ok, Merged, Conflicts} = merge_one(AccTrees, InsertTree, [], false),
+ {Merged, Conflicts or AccConflicts}
end,
{A, false}, B),
if HasConflicts or