Skip to content

Commit

Permalink
If Mirror's frequency is not specified, Mirror will do one and only i…
Browse files Browse the repository at this point in the history
…ne synchronization
  • Loading branch information
yrashk committed Oct 3, 2012
1 parent 6b6f86a commit 16a6799
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/repositories/mirror.ex
Expand Up @@ -2,8 +2,12 @@ defrecord Expm.Repository.Mirror, source: nil, destination: nil, frequency: 1000
defoverridable new: 1
def new(opts) do
rec = super(opts)
{:ok, tref } = :timer.apply_interval(frequency(rec), __MODULE__, :update, [rec])
timer(tref, rec)
case frequency(rec) do
nil -> update(rec) ; rec
frequency ->
{:ok, tref} = :timer.apply_interval(frequency, __MODULE__, :update, [rec])
timer(tref, rec)
end
end

def cancel(rec) do
Expand Down

0 comments on commit 16a6799

Please sign in to comment.