Skip to content

Commit bd3d68c

Browse files
committed
Improve reliability of compiler cache
1. Check if timestamps mismatch, instead of ordering 2. Ensure manifests are removed before .beam files on clean
1 parent 668fb69 commit bd3d68c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/mix/lib/mix/compilers/elixir.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ defmodule Mix.Compilers.Elixir do
299299
"""
300300
def clean(manifest, compile_path) do
301301
{modules, _} = read_manifest(manifest)
302+
_ = File.rm(manifest)
302303

303304
Enum.each(modules, fn {module, _} ->
304305
File.rm(beam_path(compile_path, module))
@@ -440,7 +441,7 @@ defmodule Mix.Compilers.Elixir do
440441

441442
size != last_size or
442443
has_any_key?(stale_modules, modules) or
443-
(last_mtime > mtime and
444+
(last_mtime != mtime and
444445
(missing_beam_file?(dest, modules) or digest_changed?(source, digest))) ->
445446
[source]
446447

@@ -479,7 +480,7 @@ defmodule Mix.Compilers.Elixir do
479480
digest != nil
480481

481482
%{^external => {last_mtime, last_size}} ->
482-
size != last_size or (last_mtime > mtime and digest_changed?(external, digest))
483+
size != last_size or (last_mtime != mtime and digest_changed?(external, digest))
483484
end
484485
end
485486

lib/mix/lib/mix/compilers/erlang.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ defmodule Mix.Compilers.Erlang do
199199
Removes compiled files for the given `manifest`.
200200
"""
201201
def clean(manifest) do
202-
Enum.each(read_manifest(manifest), fn {file, _} -> File.rm(file) end)
202+
contents = read_manifest(manifest)
203203
File.rm(manifest)
204+
Enum.each(contents, fn {file, _} -> File.rm(file) end)
204205
end
205206

206207
@doc """

0 commit comments

Comments
 (0)