summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Harrop <rob@rabbitmq.com>2010-11-25 15:33:27 +0000
committerRob Harrop <rob@rabbitmq.com>2010-11-25 15:33:27 +0000
commitb0c2cac6b7d7b3efb9df6d39dfaba5ca7b90fc1b (patch)
treec422eebeb996df66aca6c1e736f6792a15bf3f73
parent72d53300f2b787dd8d8ed035be9b02d539ca6019 (diff)
parent27a6eb231e087c6ae6a358d1ee207840bd1885a6 (diff)
downloadrabbitmq-server-git-b0c2cac6b7d7b3efb9df6d39dfaba5ca7b90fc1b.tar.gz
merging heads together
-rw-r--r--src/rabbit_queue_index.erl27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl
index a312e8a808..43dbf9d4cb 100644
--- a/src/rabbit_queue_index.erl
+++ b/src/rabbit_queue_index.erl
@@ -1039,21 +1039,24 @@ transform_queue(Dir, Gatherer, {JournalFun, SegmentFun}) ->
transform_file(Path, Fun) ->
PathTmp = Path ++ ".upgrade",
- Size = filelib:file_size(Path),
-
- {ok, PathTmpHdl} =
- file_handle_cache:open(PathTmp, ?WRITE_MODE,
- [{write_buffer, infinity}]),
+ case filelib:file_size(Path) of
+ 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