Fix farmware install upgrade, downgrade

This commit is contained in:
Connor Rigby 2017-12-11 16:30:53 -08:00
parent 64f4b269a1
commit 32508b9e77

View file

@ -126,7 +126,13 @@ defmodule Farmbot.Farmware.Installer do
install_path = install_path(fw_name)
manifest_path = Path.join(install_path, "manifest.json")
if File.exists?(manifest_path) do
{:error, {fw_name, fw_version, :already_installed}}
case File.read!(manifest_path) |> Poison.decode!() |> Map.get("version") |> Version.parse!() |> Version.compare(fw_version) do
:eq ->
{:error, {fw_name, fw_version, :already_installed}}
_ ->
File.rm_rf(install_path)
File.mkdir_p(install_path)
end
else
File.mkdir_p(install_path)
end