Skip to content

Commit 00bed7d

Browse files
author
José Valim
committed
Ensure old manifests can be upgraded
1 parent 9f61cbc commit 00bed7d

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,14 @@ defmodule Mix.Compilers.Elixir do
488488
try do
489489
manifest |> File.read!() |> :erlang.binary_to_term()
490490
rescue
491-
_ -> {[], []}
491+
_ ->
492+
delete_old_manifest(manifest, compile_path)
493+
{[], []}
492494
else
493495
[@manifest_vsn | data] ->
494496
split_manifest(data, compile_path)
495497

496-
[v | data] when v in [:v4, :v5, :v6, :v7, :v8] ->
498+
[v | data] when is_integer(v) ->
497499
for module <- data,
498500
is_record(module, :module),
499501
do: File.rm(Path.join(compile_path, module(module, :beam)))
@@ -505,6 +507,26 @@ defmodule Mix.Compilers.Elixir do
505507
end
506508
end
507509

510+
defp delete_old_manifest(manifest, compile_path) do
511+
manifest = Path.expand("../../.compile.elixir", manifest)
512+
513+
try do
514+
manifest
515+
|> File.read!()
516+
|> :erlang.binary_to_term()
517+
|> case do
518+
[v | data] when v in [:v4, :v5, :v6, :v7, :v8] ->
519+
for module <- data,
520+
is_record(module, :module),
521+
do: File.rm(Path.join(compile_path, module(module, :beam)))
522+
end
523+
524+
File.rm(manifest)
525+
rescue
526+
_ -> :ok
527+
end
528+
end
529+
508530
defp split_manifest(data, compile_path) do
509531
Enum.reduce(data, {[], []}, fn
510532
module() = module, {modules, sources} ->

0 commit comments

Comments
 (0)