Make couch_server:delete_file response to match couch_file:delete

Function `couch_server:delete_file` returns tuples with either `deleted`
or `{renamed, Filename}` tags. We don't use this format for anything
and it contradicts general notion of `couch_file:delete` to keep response
in-line with erlang's module `file` symantics.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/bc3ecda3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/bc3ecda3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/bc3ecda3

Branch: refs/heads/master
Commit: bc3ecda3dd4ad4f24371f3ce94c0d5e3803eaf2b
Parents: 636d30a
Author: Eric Avdey <e...@eiri.ca>
Authored: Wed Apr 20 12:01:01 2016 -0300
Committer: Eric Avdey <e...@eiri.ca>
Committed: Thu Apr 28 13:09:35 2016 -0300

----------------------------------------------------------------------
 src/couch_server.erl | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/bc3ecda3/src/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_server.erl b/src/couch_server.erl
index 058ce22..dc50e82 100644
--- a/src/couch_server.erl
+++ b/src/couch_server.erl
@@ -462,7 +462,7 @@ handle_call({delete, DbName, Options}, _From, Server) ->
         couch_db_plugin:on_delete(DbName, Options),
 
         case delete_file(Server#server.root_dir, FullFilepath, Options) of
-        {ok, _} ->
+        ok ->
             couch_event:notify(DbName, deleted),
             {reply, ok, Server2};
         {error, enoent} ->
@@ -542,22 +542,16 @@ db_closed(Server, Options) ->
 delete_file(RootDir, FullFilePath, Options) ->
     Async = not lists:member(sync, Options),
     RenameOnDelete = config:get_boolean("couchdb", "rename_on_delete", false),
-    case {Async, RenameOnDelete} of
-        {_, true} ->
+    case RenameOnDelete of
+        true ->
             rename_on_delete(FullFilePath);
-        {Async, false} ->
-            case couch_file:delete(RootDir, FullFilePath, Async) of
-                ok -> {ok, deleted};
-                Else -> Else
-            end
+        false ->
+            couch_file:delete(RootDir, FullFilePath, Async)
     end.
 
 rename_on_delete(Original) ->
     DeletedFileName = deleted_filename(Original),
-    case file:rename(Original, DeletedFileName) of
-        ok -> {ok, {renamed, DeletedFileName}};
-        Else -> Else
-    end.
+    file:rename(Original, DeletedFileName).
 
 deleted_filename(Original) ->
     {{Y,Mon,D}, {H,Min,S}} = calendar:universal_time(),

Reply via email to