summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Harrop <rob@rabbitmq.com>2010-11-25 16:28:03 +0000
committerRob Harrop <rob@rabbitmq.com>2010-11-25 16:28:03 +0000
commit1393548d7b7231a8deef17bd385f6445935118bf (patch)
treeb97bc785f5dc51ac972daa281124e09e6d0a2a01
parent8fa783acc1f1380907ef6ff86098844b1340b92d (diff)
parent9029a0ad67fd1c9a486b6468f8dffe4812f54454 (diff)
downloadrabbitmq-server-1393548d7b7231a8deef17bd385f6445935118bf.tar.gz
Merge with default
-rw-r--r--src/rabbit_queue_index.erl32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl
index b646f330..76c0a4ef 100644
--- a/src/rabbit_queue_index.erl
+++ b/src/rabbit_queue_index.erl
@@ -1054,29 +1054,25 @@ transform_queue(Dir, Gatherer, {JournalFun, SegmentFun}) ->
transform_file(Path, Fun) ->
PathTmp = Path ++ ".upgrade",
case filelib:file_size(Path) of
- 0 ->
- ok;
- Size ->
- {ok, PathTmpHdl} =
- file_handle_cache:open(PathTmp, ?WRITE_MODE,
- [{write_buffer, infinity}]),
+ 0 -> ok;
+ Size -> {ok, PathTmpHdl} =
+ file_handle_cache:open(PathTmp, ?WRITE_MODE,
+ [{write_buffer, infinity}]),
- {ok, PathHdl} = file_handle_cache:open(
- Path, [{read_ahead, Size} | ?READ_MODE], []),
- {ok, Content} = file_handle_cache:read(PathHdl, Size),
- ok = file_handle_cache:close(PathHdl),
+ {ok, PathHdl} = file_handle_cache:open(
+ Path, [{read_ahead, Size} | ?READ_MODE], []),
+ {ok, Content} = file_handle_cache:read(PathHdl, Size),
+ ok = file_handle_cache:close(PathHdl),
- ok = drive_transform_fun(Fun, PathTmpHdl, Content),
+ ok = drive_transform_fun(Fun, PathTmpHdl, Content),
- ok = file_handle_cache:close(PathTmpHdl),
- ok = file:rename(PathTmp, Path)
+ ok = file_handle_cache:close(PathTmpHdl),
+ ok = file:rename(PathTmp, Path)
end.
drive_transform_fun(Fun, Hdl, Contents) ->
case Fun(Contents) of
- stop ->
- ok;
- {Output, Contents1} ->
- ok = file_handle_cache:append(Hdl, Output),
- drive_transform_fun(Fun, Hdl, Contents1)
+ stop -> ok;
+ {Output, Contents1} -> ok = file_handle_cache:append(Hdl, Output),
+ drive_transform_fun(Fun, Hdl, Contents1)
end.