Browse Source

delete old beam when recompile dtl - this partial fixing white screen

221V 3 years ago
parent
commit
2545263f49
1 changed files with 15 additions and 6 deletions
  1. 15 6
      src/active_compile_files.erl

+ 15 - 6
src/active_compile_files.erl

@@ -221,18 +221,24 @@ compile_one_dtl(File_Path, Path, Ebin_Dir, SourceExt) ->
   
   Opts = dtl_opts(DocRoot, OutDir, SourceExt, ModuleExt),
   
-  ModuleName = module_name(File_Path, SourceExt, ModuleExt),
-  BeamName = beam_path_name(OutDir, erlang:atom_to_list(ModuleName)),
+  Module_Name = module_name(File_Path, SourceExt, ModuleExt),
+  Beam_Name = beam_path_name(OutDir, erlang:atom_to_list(Module_Name)),
   
-  case is_compiled(BeamName, File_Path) of
+  case is_compiled(Beam_Name, File_Path) of
     false ->
+      
+      delete_old_beam(Beam_Name),
+      
       io:format("~nCompiling ~p: ", [File_Path]),
       
-      case erlydtl:compile(File_Path, ModuleName, Opts) of
+      RZ = erlydtl:compile(File_Path, Module_Name, Opts),
+      %io:format("RZ: ~p~n", [RZ]),
+      case RZ of
         {error, Error} ->
           io:format("~nError: ~p~n", [Error]);
-        _ ->
-          file:change_time(BeamName, calendar:local_time()),
+        {ok, Module_Name} ->
+          file:change_time(Beam_Name, calendar:local_time()),
+          
           io:format("ok~n", [])
       end;
     _ ->
@@ -267,4 +273,7 @@ last_modified(File) ->
       calendar:datetime_to_gregorian_seconds(N)
   end.
 
+delete_old_beam(File) ->
+  file:delete(File).
+