You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2018/03/09 18:09:17 UTC

[couchdb] branch master updated (6f294c1 -> f999071)

This is an automated email from the ASF dual-hosted git repository.

jan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    from 6f294c1  fix: compaction daemon symlink resolution and log level #1097
     new b05c177  Proper error handling for file:open() call
     new 42c89ba  fix whitespace
     new f999071  style fixes as per @davisp

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/couch/src/couch_file.erl | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
jan@apache.org.

[couchdb] 03/03: style fixes as per @davisp

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit f999071ec6b347b27526047cc16a00811e21fdd9
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Fri Mar 9 17:47:22 2018 +0100

    style fixes as per @davisp
---
 src/couch/src/couch_file.erl | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index 260a88c..9f668ea 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -216,9 +216,9 @@ sync(Filepath) when is_list(Filepath) ->
     case file:open(Filepath, [append, raw]) of
         {ok, Fd} ->
             try ok = file:sync(Fd) after ok = file:close(Fd) end;
-        Error ->
-            throw(Error)
-        end;
+        {error, Error} ->
+            erlang:error(Error)
+    end;
 sync(Fd) ->
     gen_server:call(Fd, sync, infinity).
 
@@ -393,18 +393,18 @@ init({Filepath, Options, ReturnPid, Ref}) ->
         % 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} ->
-             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 ->
-                  init_status_error(ReturnPid, Ref, Error)
-                end;
+            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 ->
+                     init_status_error(ReturnPid, Ref, Error)
+            end;
         Error ->
             init_status_error(ReturnPid, Ref, Error)
         end

-- 
To stop receiving notification emails like this one, please contact
jan@apache.org.

[couchdb] 02/03: fix whitespace

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 42c89bad801f1a6230dd2867d776e8513372137f
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Fri Mar 9 17:46:52 2018 +0100

    fix whitespace
---
 src/couch/src/couch_file.erl | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index 8a1b205..260a88c 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -214,11 +214,11 @@ truncate(Fd, Pos) ->
 
 sync(Filepath) when is_list(Filepath) ->
     case file:open(Filepath, [append, raw]) of
-      {ok, Fd} ->
-         try ok = file:sync(Fd) after ok = file:close(Fd) end;
-      Error ->
-         throw(Error)
-      end;
+        {ok, Fd} ->
+            try ok = file:sync(Fd) after ok = file:close(Fd) end;
+        Error ->
+            throw(Error)
+        end;
 sync(Fd) ->
     gen_server:call(Fd, sync, infinity).
 

-- 
To stop receiving notification emails like this one, please contact
jan@apache.org.

[couchdb] 01/03: Proper error handling for file:open() call

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit b05c1775fb85d7fb979879fd16dba4ed736a2a96
Author: AlexanderKaraberov <al...@spotme.com>
AuthorDate: Wed Feb 14 17:10:32 2018 +0100

    Proper error handling for file:open() call
---
 src/couch/src/couch_file.erl | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index 7b6f519..8a1b205 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 ->
+         throw(Error)
+      end;
 sync(Fd) ->
     gen_server:call(Fd, sync, infinity).
 
@@ -389,14 +393,18 @@ init({Filepath, Options, ReturnPid, Ref}) ->
         % 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}};
+             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 ->
+                  init_status_error(ReturnPid, Ref, Error)
+                end;
         Error ->
             init_status_error(ReturnPid, Ref, Error)
         end

-- 
To stop receiving notification emails like this one, please contact
jan@apache.org.