Skip to content

Commit

Permalink
Improve object-storage-container's launch for leo-project/leofs/issue…
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukehara committed Feb 8, 2016
1 parent 9806de8 commit 8756530
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/leo_object_storage_haystack.erl
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,17 @@ add_incorrect_data(WriteHandler, Offset, Data) ->
create_file(FilePath) ->
case catch file:open(FilePath, [raw, write, binary, append]) of
{ok, PutFileHandler} ->
case file:position(PutFileHandler, eof) of
{ok, Offset} when Offset == 0 ->
put_super_block(PutFileHandler);
{ok,_Offset} ->
{ok, PutFileHandler};
{error, Cause} ->
case catch filelib:file_size(FilePath) of
{'EXIT', Cause} ->
error_logger:error_msg("~p,~p,~p,~p~n",
[{module, ?MODULE_STRING},
{function, "create_file/1"},
{line, ?LINE}, {body, Cause}]),
{error, Cause}
{error, Cause};
0 ->
put_super_block(PutFileHandler);
_FileSize ->
{ok, PutFileHandler}
end;
{error, Cause} ->
error_logger:error_msg("~p,~p,~p,~p~n",
Expand Down

3 comments on commit 8756530

@mocchira
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file:read_file_info is more efficient than filelib:file_size to retrieve the size of file when you already have a file handle.

@mocchira
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mocchira
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yosukehara
Sorry that I had a miss understanding about the file:read_file_info spec.
(I assumed the first argument take a IoDevice type)
So LGTM with this commit.

Please sign in to comment.