Skip to content

Commit

Permalink
Fix 'update' command output
Browse files Browse the repository at this point in the history
So far, ejabberd_update:update/0 returned the return value of
release_handler_1:eval_script/1.  That function returns the list of
updated but unpurged modules, i.e., modules where one or more processes
are still running an old version of the code.  Since commit
5a34020, the ejabberd 'update' command
assumes that value to be the list of updated modules instead.  As
that seems more useful, modify ejabberd_update:update/0 accordingly.
This fixes the 'update' command output.
  • Loading branch information
weiss committed Sep 14, 2024
1 parent 3469a51 commit 3d9a5a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/ejabberd_admin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ update_module(ModuleNameString) ->
case ejabberd_update:update([ModuleName]) of
{ok, []} ->
{ok, "Not updated: "++ModuleNameString};
{ok, [{ModuleName, _}]} ->
{ok, [ModuleName]} ->
{ok, "Updated: "++ModuleNameString};
{error, Reason} -> {error, Reason}
end.
Expand Down
34 changes: 21 additions & 13 deletions src/ejabberd_update.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@
%% Update all the modified modules
update() ->
case update_info() of
{ok, Dir, _UpdatedBeams, _Script, LowLevelScript, _Check} ->
Eval =
eval_script(
LowLevelScript, [],
[{ejabberd, "", filename:join(Dir, "..")}]),
?DEBUG("Eval: ~p~n", [Eval]),
Eval;
{ok, Dir, UpdatedBeams, _Script, LowLevelScript, _Check} ->
case eval_script(
LowLevelScript, [],
[{ejabberd, "", filename:join(Dir, "..")}]) of
{ok, _} ->
?DEBUG("Updated: ~p~n", [UpdatedBeams]),
{ok, UpdatedBeams};
Eval ->
?DEBUG("Eval: ~p~n", [Eval]),
Eval
end;
{error, Reason} ->
{error, Reason}
end.
Expand All @@ -56,12 +60,16 @@ update(ModulesToUpdate) ->
UpdatedBeamsNow =
[A || A <- UpdatedBeamsAll, B <- ModulesToUpdate, A == B],
{_, LowLevelScript, _} = build_script(Dir, UpdatedBeamsNow),
Eval =
eval_script(
LowLevelScript, [],
[{ejabberd, "", filename:join(Dir, "..")}]),
?DEBUG("Eval: ~p~n", [Eval]),
Eval;
case eval_script(
LowLevelScript, [],
[{ejabberd, "", filename:join(Dir, "..")}]) of
{ok, _} ->
?DEBUG("Updated: ~p~n", [UpdatedBeamsNow]),
{ok, UpdatedBeamsNow};
Eval ->
?DEBUG("Eval: ~p~n", [Eval]),
Eval
end;
{error, Reason} ->
{error, Reason}
end.
Expand Down

0 comments on commit 3d9a5a1

Please sign in to comment.