Commit 374e5483 authored by Leo Iannacone's avatar Leo Iannacone

use callback instead of updater - fix function name - fix err/error variable name

parent 21db8f2e
......@@ -89,7 +89,7 @@ __send_file = (event_name, socket, data, last_lines) ->
file_path = utils.get_file_path(data)
fs.readFile file_path, "utf8", (err, content) ->
if err
utils.errors_handler "client:__send_file", err, socket
utils.errors_handler("client:__send_file", err, socket)
return
data.file.orig_name = file_path.split("/").pop()
if last_lines > 0
......@@ -100,13 +100,13 @@ __send_file = (event_name, socket, data, last_lines) ->
config.routes.debomatic)
socket.emit event_name, data
return
return
__handler_get_file = (socket, data) ->
file_path = utils.get_file_path(data)
send = (event_name, socket, data) ->
data.file.content = null
socket.emit event_name, data
socket.emit(event_name, data)
utils.watch_path_onsocket(_e.file_newcontent, socket, data, file_path, send)
if data.file.name in config.web.file.preview and not data.file.force
......
......@@ -59,7 +59,7 @@ get_files_list = (dir, onlyDirectories, callback) ->
callback(result)
watch_path_onsocket = (event_name, socket, data, watch_path, updater) ->
watch_path_onsocket = (event_name, socket, data, watch_path, callback) ->
socket_watchers = socket.watchers or {}
try
watcher = socket_watchers[event_name]
......@@ -75,13 +75,13 @@ watch_path_onsocket = (event_name, socket, data, watch_path, updater) ->
persistent: true,
(event, fileName) ->
if event is "rename"
updater(event_name, socket, data))
callback(event_name, socket, data))
else if stats.isFile()
watcher = new Tail(watch_path)
watcher.on("line", (new_content, tailInfo) ->
watcher.on "line", (new_content, tailInfo) ->
data.file.new_content = new_content + "\n"
updater event_name, socket, data)
callback(event_name, socket, data)
watcher.on "error", (msg) ->
socket.emit config.events.error, msg
......@@ -91,7 +91,7 @@ watch_path_onsocket = (event_name, socket, data, watch_path, updater) ->
catch err
errors_handler("watch_path_onsocket <- " +
arguments_.callee.caller.name,
arguments.callee.caller.name,
err, socket)
return
......@@ -113,7 +113,7 @@ send_distributions = (socket) ->
socket.emit config.events.broadcast.distributions, distributions
errors_handler = (from, error, socket) ->
errors_handler = (from, err, socket) ->
from = "NO SOCKET: " + from unless socket
console.error from, err.message
socket.emit config.events.error, err.message if socket
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment