From 16a67996a8cd7f7541b07fdb513cfe31a820d896 Mon Sep 17 00:00:00 2001 From: Yurii Rashkovskii Date: Wed, 3 Oct 2012 01:26:06 -0700 Subject: [PATCH] If Mirror's frequency is not specified, Mirror will do one and only ine synchronization --- lib/repositories/mirror.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/repositories/mirror.ex b/lib/repositories/mirror.ex index 2add4fc..2e6b633 100644 --- a/lib/repositories/mirror.ex +++ b/lib/repositories/mirror.ex @@ -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