-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incremental compilation for Mix.install/2 #13756
Incremental compilation for Mix.install/2 #13756
Conversation
entries | ||
|> Enum.filter(&String.starts_with?(&1, id_without_deps)) | ||
|> Enum.map(&Path.join(version_dir, &1)) | ||
|> Enum.map(&{&1, File.stat!(&1).mtime}) | ||
|> Enum.max_by(&elem(&1, 1), fn -> nil end) | ||
|> case do | ||
{latest_dir, _mtime} -> latest_dir | ||
nil -> nil | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this would be easier to read?
I lost track on 1052, I'm just guessing what should be the result.
entries | |
|> Enum.filter(&String.starts_with?(&1, id_without_deps)) | |
|> Enum.map(&Path.join(version_dir, &1)) | |
|> Enum.map(&{&1, File.stat!(&1).mtime}) | |
|> Enum.max_by(&elem(&1, 1), fn -> nil end) | |
|> case do | |
{latest_dir, _mtime} -> latest_dir | |
nil -> nil | |
end | |
for entry <- entries, | |
String.starts_with?(entry, id_without_deps), | |
current_path = Path.join(version_dir, entry), | |
%{mtime: current_mtime} = File.stat!(current_path), | |
reduce: {nil, nil} do | |
{nil, nil} -> {current_path, current_mtime} | |
{_path, mtime} when current_mtime > mtime -> {current_path, current_mtime} | |
acc -> acc | |
end | |
|> elem(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH for me, I like pipe operator more, but thank you for advice.
Hi @tywhisky, thank you for the PR, but the actual implementation is much more complex than that (to the point we are not sure it is worth it given the complexity). The issue is that we want to allow multiple The issue is not to locate the previous version, sorry for any confusion. :( |
@josevalim That's fine, there's always a lot to learn from reading the source code, I just hope I didn't add to the trouble😂, and I actually did consider the meaning of instance along the way, I'll be more prepared next time. |
No worries! If you learned something, then it was worth it. Hopefully we will merge the next one! |
#12293
I see that file copying has been implemented in previous PRs. So if I'm not misunderstanding the requirements. I think the issue is how to locate to the previous version.
My solution:
install_project_dir
to encode the generated path.String.starts_with?
to find the most recently modified version.Users can still specify the restore directory by manually exporting the environment variable.