summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Harrop <rob@rabbitmq.com>2010-11-25 15:31:44 +0000
committerRob Harrop <rob@rabbitmq.com>2010-11-25 15:31:44 +0000
commit27a6eb231e087c6ae6a358d1ee207840bd1885a6 (patch)
tree09211b8d4bdfaa8470b19cadc49f64af9d4e1113 /src
parentaec5a6cec71e341d81f500ab281f6f3ad09f7f49 (diff)
parent351c82b7b83c301646015d2a07336a7e73c060a8 (diff)
downloadrabbitmq-server-git-27a6eb231e087c6ae6a358d1ee207840bd1885a6.tar.gz
Merge bug23548 into default
Diffstat (limited to 'src')
-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