25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Fix reading room jids from file for create and destroy_rooms_file commands

This commit is contained in:
Badlop 2016-11-04 16:54:31 +01:00
parent bab71f0832
commit 5e723bc90e

View File

@ -514,7 +514,7 @@ destroy_room({N, H, SH}) ->
%% The file encoding must be UTF-8 %% The file encoding must be UTF-8
destroy_rooms_file(Filename) -> destroy_rooms_file(Filename) ->
{ok, F} = file:open(Filename, [read, binary]), {ok, F} = file:open(Filename, [read]),
RJID = read_room(F), RJID = read_room(F),
Rooms = read_rooms(F, RJID, []), Rooms = read_rooms(F, RJID, []),
file:close(F), file:close(F),
@ -533,7 +533,7 @@ read_room(F) ->
eof -> eof; eof -> eof;
String -> String ->
case io_lib:fread("~s", String) of case io_lib:fread("~s", String) of
{ok, [RoomJID], _} -> split_roomjid(RoomJID); {ok, [RoomJID], _} -> split_roomjid(list_to_binary(RoomJID));
{error, What} -> {error, What} ->
io:format("Parse error: what: ~p~non the line: ~p~n~n", [What, String]) io:format("Parse error: what: ~p~non the line: ~p~n~n", [What, String])
end end
@ -551,7 +551,7 @@ split_roomjid(RoomJID) ->
%%---------------------------- %%----------------------------
create_rooms_file(Filename) -> create_rooms_file(Filename) ->
{ok, F} = file:open(Filename, [read, binary]), {ok, F} = file:open(Filename, [read]),
RJID = read_room(F), RJID = read_room(F),
Rooms = read_rooms(F, RJID, []), Rooms = read_rooms(F, RJID, []),
file:close(F), file:close(F),