Skip to content

Commit

Permalink
call get_callback only once
Browse files Browse the repository at this point in the history
  • Loading branch information
tex committed Dec 11, 2012
1 parent 04a0b66 commit 3534f57
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{deps, [
{erlinotify, ".*", {git, "https://github.com/tex/erlinotify.git", "HEAD"}}
]}.

6 changes: 4 additions & 2 deletions src/ssync.erl
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@ watch([F|R]) ->
watch(R).

watch_recursive(Path, CallbackName) ->
Callback = get_callback(CallbackName),
Dirs = subdirs(Path) ++ [{dir, Path}],
lists:foreach(fun({dir, X}) -> erlinotify:watch(X, get_callback(CallbackName)) end,
lists:flatten(Dirs) ).

[erlinotify:watch(X, Callback) ||
{dir, X} <- lists:flatten(Dirs) ], ok.

get_callback(reload) ->
fun do_reload/1;
Expand Down

0 comments on commit 3534f57

Please sign in to comment.