cleanup
This commit is contained in:
parent
d69ac3cf4d
commit
66c8baab9b
|
@ -13,6 +13,8 @@ defmodule Farmbot.Bootstrap.Authorization do
|
||||||
@typedoc "Token that was fetched with the credentials."
|
@typedoc "Token that was fetched with the credentials."
|
||||||
@type token :: binary
|
@type token :: binary
|
||||||
|
|
||||||
|
require Logger
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Callback for an authorization implementation.
|
Callback for an authorization implementation.
|
||||||
Should return {:ok, token} | {:error, term}
|
Should return {:ok, token} | {:error, term}
|
||||||
|
@ -34,7 +36,7 @@ defmodule Farmbot.Bootstrap.Authorization do
|
||||||
# If we got maintance mode, a 5xx error etc, just sleep for a few seconds
|
# If we got maintance mode, a 5xx error etc, just sleep for a few seconds
|
||||||
# and try again.
|
# and try again.
|
||||||
{:ok, {{_, code, _}, _, _}} ->
|
{:ok, {{_, code, _}, _, _}} ->
|
||||||
Logger.error "Failed to authorize due to server error."
|
Logger.error "Failed to authorize due to server error: #{code}"
|
||||||
Process.sleep(5000)
|
Process.sleep(5000)
|
||||||
authorize(email, password, server)
|
authorize(email, password, server)
|
||||||
err -> err
|
err -> err
|
||||||
|
|
|
@ -110,7 +110,7 @@ defmodule Farmbot.Repo do
|
||||||
defp do_apply_sync_cmd(repo, %{id: id, kind: mod, body: nil} = sync_cmd) do
|
defp do_apply_sync_cmd(repo, %{id: id, kind: mod, body: nil} = sync_cmd) do
|
||||||
# an object was deleted.
|
# an object was deleted.
|
||||||
if Code.ensure_loaded?(mod) do
|
if Code.ensure_loaded?(mod) do
|
||||||
Logger.warn "Applying sync_cmd (delete) : #{inspect sync_cmd} on #{repo}"
|
Logger.debug "Applying sync_cmd (#{mod}: delete) on #{repo}"
|
||||||
case repo.get(mod, id) do
|
case repo.get(mod, id) do
|
||||||
nil -> :ok
|
nil -> :ok
|
||||||
existing ->
|
existing ->
|
||||||
|
@ -125,7 +125,7 @@ defmodule Farmbot.Repo do
|
||||||
|
|
||||||
defp do_apply_sync_cmd(repo, %{id: id, kind: mod, body: obj} = sync_cmd) do
|
defp do_apply_sync_cmd(repo, %{id: id, kind: mod, body: obj} = sync_cmd) do
|
||||||
if Code.ensure_loaded?(mod) do
|
if Code.ensure_loaded?(mod) do
|
||||||
Logger.warn "Applying sync_cmd (insert_or_update): #{inspect sync_cmd} on #{repo}"
|
Logger.debug "Applying sync_cmd (#{mod}: insert_or_update on #{repo}"
|
||||||
|
|
||||||
# We need to check if this object exists in the database.
|
# We need to check if this object exists in the database.
|
||||||
case repo.get(mod, id) do
|
case repo.get(mod, id) do
|
||||||
|
|
Loading…
Reference in a new issue