8000 Don't rewrite app files if contents are the same by lrascao · Pull Request #565 · erlware/relx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Don't rewrite app files if contents are the same #565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/rlx_prv_assembler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ format_error({start_clean_script_generation_error, Module, Errors}) ->
rlx_util:indent(2), Module:format_error(Errors)];
format_error({strip_release, Reason}) ->
io_lib:format("Stripping debug info from release beam files failed becuase ~s",
[beam_lib:format_error(Reason)]).
[beam_lib:format_error(Reason)]);
format_error({rewrite_app_file, AppFile, Error}) ->
io_lib:format("Unable to rewrite .app file ~s due to ~p",
[AppFile, Error]).

%%%===================================================================
%%% Internal Functions
Expand Down Expand Up @@ -255,13 +258,16 @@ rewrite_app_file(State, App, TargetDir) ->
,AppData2
,{modules, OldModules -- ExcludedModules})
end,
Spec = io_lib:format("~p.\n", [{application, AppName, AppData3}]),
write_file_if_contents_differ(AppFile, Spec).
Spec = [{application, AppName, AppData3}],
case write_file_if_contents_differ(AppFile, Spec) of
ok -> ok;
Error -> ?RLX_ERROR({rewrite_app_file, AppFile, Error})
end.

write_file_if_contents_differ(Filename, Bytes) ->
ToWrite = iolist_to_binary(Bytes),
case file:read_file(Filename) of
{ok, ToWrite} ->
write_file_if_contents_differ(Filename, Spec) ->
ToWrite = io_lib:format("~p.\n", Spec),
case file:consult(Filename) of
{ok, Spec} ->
ok;
{ok, _} ->
file:write_file(Filename, ToWrite);
Expand Down
0