Add conditional for autosync after eunlock

This commit is contained in:
Connor Rigby 2017-12-07 14:53:25 -08:00
parent 23dc7f5bf3
commit 2f3f2093a2
2 changed files with 7 additions and 2 deletions

View file

@ -175,7 +175,10 @@ defmodule Farmbot.Firmware do
defp do_begin_cmd(%Current{fun: fun, args: args, from: _from} = current, state, dispatch) do
# Logger.debug 3, "Firmware command: #{fun}#{inspect(args)}"
if fun == :emergency_unlock, do: Farmbot.BotState.set_sync_status(:sync_now)
is_unlock_cmd = fun == :emergency_unlock
auto_sync = Farmbot.System.ConfigStorage.get_config_value(:bool, "settings", "auto_sync")
if is_unlock_cmd && auto_sync, do: Farmbot.BotState.set_sync_status(:sync_now)
if is_unlock_cmd && !auto_sync, do: Farmbot.BotState.set_sync_status(:synced)
case apply(state.handler_mod, fun, [state.handler | args]) do
:ok ->

View file

@ -35,7 +35,9 @@ defmodule Farmbot.System do
@spec factory_reset(unparsed_reason) :: no_return
def factory_reset(reason) do
if Process.whereis Farmbot.System.ConfigStorage do
unless Farmbot.System.ConfigStorage.get_config_value(:bool, "settings", "disable_factory_reset") do
if Farmbot.System.ConfigStorage.get_config_value(:bool, "settings", "disable_factory_reset") do
reboot(reason)
else
do_reset(reason)
end
else