diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-15 14:58:51 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-15 14:58:51 +0100 |
commit | fccf0a1b26a0c3602f9da5f8dd74a58881931d9e (patch) | |
tree | c1d85b77dea55122cc8703969a8cf2d7f091e2ab | |
parent | 699f9556f5f6bc743d7b1055b2f81b27c6d981b2 (diff) | |
download | rabbitmq-server-fccf0a1b26a0c3602f9da5f8dd74a58881931d9e.tar.gz |
minor refactor
-rw-r--r-- | src/rabbit_msg_store.erl | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl index 8df700e1..3d019124 100644 --- a/src/rabbit_msg_store.erl +++ b/src/rabbit_msg_store.erl @@ -575,12 +575,8 @@ init([Server, BaseDir, ClientRefs, {MsgRefDeltaGen, MsgRefDeltaGenInit}]) -> false -> count_msg_refs(MsgRefDeltaGen, MsgRefDeltaGenInit, State) end, - %% recover_index_and_client_refs could have wiped out all files, - %% so need to look again at what files we have to scan - Files = [filename_to_num(FileName) || - FileName <- list_sorted_file_names(Dir, ?FILE_EXTENSION)], {Offset, State1 = #msstate { current_file = CurFile }} = - build_index(AllCleanShutdown, Files, State), + build_index(AllCleanShutdown, State), %% read is only needed so that we can seek {ok, CurHdl} = open_file(Dir, filenum_to_name(CurFile), @@ -1308,8 +1304,7 @@ find_contiguous_block_prefix([{Guid, TotalSize, ExpectedOffset} | Tail], find_contiguous_block_prefix([_MsgAfterGap | _Tail], ExpectedOffset, Guids) -> {ExpectedOffset, Guids}. -build_index(true, _Files, State = #msstate { - file_summary_ets = FileSummaryEts }) -> +build_index(true, State = #msstate { file_summary_ets = FileSummaryEts }) -> ets:foldl( fun (#file_summary { valid_total_size = ValidTotalSize, file_size = FileSize, @@ -1321,12 +1316,15 @@ build_index(true, _Files, State = #msstate { sum_file_size = SumFileSize + FileSize, current_file = File }} end, {0, State}, FileSummaryEts); -build_index(false, Files, State) -> +build_index(false, State = #mssstate { dir = Dir }) -> {ok, Pid} = gatherer:start_link(), - case Files of - [] -> build_index(Pid, undefined, [State #msstate.current_file], State); - _ -> {Offset, State1} = build_index(Pid, undefined, Files, State), - {Offset, lists:foldl(fun delete_file_if_empty/2, State1, Files)} + case [filename_to_num(FileName) || + FileName <- list_sorted_file_names(Dir, ?FILE_EXTENSION)] of + [] -> build_index(Pid, undefined, [State #msstate.current_file], + State); + Files -> {Offset, State1} = build_index(Pid, undefined, Files, State), + {Offset, lists:foldl(fun delete_file_if_empty/2, + State1, Files)} end. build_index(Gatherer, Left, [], |