Skip to content

Commit

Permalink
Fix race condition in getting time.
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor Rigby committed Sep 12, 2018
1 parent e8e775c commit 35bccc9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion platform/target/network/wait_for_time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ defmodule Farmbot.Target.Network.WaitForTime do
# • 1 -- the first date comes after the second one

defp wait_for_time do
case Timex.compare(NaiveDateTime.utc_now(), get_file_time()) do
case Nerves.Time.synchronized?() && Timex.compare(NaiveDateTime.utc_now(), get_file_time()) do
1 -> :ok
_ ->
Nerves.Time.restart_ntpd()
Process.sleep(1000)
# Logger.warn "Waiting for time."
wait_for_time()
Expand Down

0 comments on commit 35bccc9

Please sign in to comment.