Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/mix/lib/mix/compilers/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ defmodule Mix.Compilers.Elixir do

defp stale_external?({external, {mtime, size}, digest}, sources_stats) do
case sources_stats do
%{^external => {0, 0}} ->
%{^external => {0, -1}} ->
digest != nil

%{^external => {last_mtime, last_size}} ->
Expand Down
6 changes: 3 additions & 3 deletions lib/mix/lib/mix/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ defmodule Mix.Utils do
Returns the date the given path was last modified in posix time
and the size.

If the path does not exist, it returns the Unix epoch
(1970-01-01 00:00:00).
If the path does not exist, it returns `{0, -1}` (the Unix epoch
with size -1 to distinguish from actual 0-byte files).
"""
def last_modified_and_size(path) do
now = System.os_time(:second)
Expand All @@ -268,7 +268,7 @@ defmodule Mix.Utils do
{mtime, size}

{:error, _} ->
{0, 0}
{0, -1}
end
end

Expand Down
4 changes: 4 additions & 0 deletions lib/mix/test/mix/utils_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ defmodule Mix.UtilsTest do
assert Mix.Utils.extract_files([""], ".ex") == []
end

test "last_modified_and_size returns {0, -1} for missing files" do
assert Mix.Utils.last_modified_and_size("nonexistent") == {0, -1}
end

test "extract stale" do
# 2038-01-01 00:00:00
time = 2_145_916_800
Expand Down
Loading