From ad121ec6400e07cc80f9f9c02d6347720a3e3ef3 Mon Sep 17 00:00:00 2001 From: AICells <1713699517@qq.com> Date: Sat, 11 Apr 2020 21:21:03 +0800 Subject: [PATCH] if the file is del deal with --- src/sync/esScanner.erl | 78 ++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/src/sync/esScanner.erl b/src/sync/esScanner.erl index 48c1aca..6b9e322 100644 --- a/src/sync/esScanner.erl +++ b/src/sync/esScanner.erl @@ -499,47 +499,51 @@ errorNoFile(Module) -> recompileSrcFile(SrcFile, _EnablePatching) -> %% Get the module, src dir, and options... - {ok, SrcDir} = esUtils:getSrcDir(SrcFile), - {CompileFun, Module} = getCompileFunAndModuleName(SrcFile), - - %% Get the old binary code... - OldBinary = getObjectCode(Module), - - case getOptions(SrcDir) of - {ok, Options} -> - case CompileFun(SrcFile, [binary, return | Options]) of - {ok, Module, Binary, Warnings} -> - reloadIfNecessary(CompileFun, SrcFile, Module, OldBinary, Binary, Options, Warnings); - - {ok, [{ok, Module, Binary, Warnings}], Warnings2} -> - reloadIfNecessary(CompileFun, SrcFile, Module, OldBinary, Binary, Options, Warnings ++ Warnings2); - - {ok, multiple, Results, Warnings} -> - Reloader = - fun({CompiledModule, Binary}) -> - {ok, _, _} = reloadIfNecessary(CompileFun, SrcFile, CompiledModule, OldBinary, Binary, Options, Warnings) - end, - lists:foreach(Reloader, Results), - {ok, [], Warnings}; - - {ok, OtherModule, _Binary, Warnings} -> - Desc = io_lib:format("Module definition (~p) differs from expected (~s)", [OtherModule, filename:rootname(filename:basename(SrcFile))]), - - Errors = [{SrcFile, {0, Module, Desc}}], - printResults(Module, SrcFile, Errors, Warnings), - {ok, Errors, Warnings}; - - {error, Errors, Warnings} -> - %% Compiling failed. Print the warnings and errors... - printResults(Module, SrcFile, Errors, Warnings), - {ok, Errors, Warnings} + case esUtils:getSrcDir(SrcFile) of + {ok, SrcDir} -> + {CompileFun, Module} = getCompileFunAndModuleName(SrcFile), + + %% Get the old binary code... + OldBinary = getObjectCode(Module), + + case getOptions(SrcDir) of + {ok, Options} -> + case CompileFun(SrcFile, [binary, return | Options]) of + {ok, Module, Binary, Warnings} -> + reloadIfNecessary(CompileFun, SrcFile, Module, OldBinary, Binary, Options, Warnings); + + {ok, [{ok, Module, Binary, Warnings}], Warnings2} -> + reloadIfNecessary(CompileFun, SrcFile, Module, OldBinary, Binary, Options, Warnings ++ Warnings2); + + {ok, multiple, Results, Warnings} -> + Reloader = + fun({CompiledModule, Binary}) -> + {ok, _, _} = reloadIfNecessary(CompileFun, SrcFile, CompiledModule, OldBinary, Binary, Options, Warnings) + end, + lists:foreach(Reloader, Results), + {ok, [], Warnings}; + + {ok, OtherModule, _Binary, Warnings} -> + Desc = io_lib:format("Module definition (~p) differs from expected (~s)", [OtherModule, filename:rootname(filename:basename(SrcFile))]), + + Errors = [{SrcFile, {0, Module, Desc}}], + printResults(Module, SrcFile, Errors, Warnings), + {ok, Errors, Warnings}; + + {error, Errors, Warnings} -> + %% Compiling failed. Print the warnings and errors... + printResults(Module, SrcFile, Errors, Warnings), + {ok, Errors, Warnings} + end; + undefined -> + Msg = io_lib:format("Unable to determine options for ~p", [SrcFile]), + esUtils:log_errors(Msg) end; - undefined -> - Msg = io_lib:format("Unable to determine options for ~p", [SrcFile]), + _ -> + Msg = io_lib:format("not find the file ~p", [SrcFile]), esUtils:log_errors(Msg) end. - printResults(Module, SrcFile, [], []) -> Msg = io_lib:format("~s:0: Recompiled.~n", [SrcFile]), case code:is_loaded(Module) of