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) -> ...@@ -89,7 +89,7 @@ __send_file = (event_name, socket, data, last_lines) ->
file_path = utils.get_file_path(data) file_path = utils.get_file_path(data)
fs.readFile file_path, "utf8", (err, content) -> fs.readFile file_path, "utf8", (err, content) ->
if err if err
utils.errors_handler "client:__send_file", err, socket utils.errors_handler("client:__send_file", err, socket)
return return
data.file.orig_name = file_path.split("/").pop() data.file.orig_name = file_path.split("/").pop()
if last_lines > 0 if last_lines > 0
...@@ -100,13 +100,13 @@ __send_file = (event_name, socket, data, last_lines) -> ...@@ -100,13 +100,13 @@ __send_file = (event_name, socket, data, last_lines) ->
config.routes.debomatic) config.routes.debomatic)
socket.emit event_name, data socket.emit event_name, data
return return
return return
__handler_get_file = (socket, data) -> __handler_get_file = (socket, data) ->
file_path = utils.get_file_path(data) file_path = utils.get_file_path(data)
send = (event_name, socket, data) -> send = (event_name, socket, data) ->
data.file.content = null 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) 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 if data.file.name in config.web.file.preview and not data.file.force
......
...@@ -59,7 +59,7 @@ get_files_list = (dir, onlyDirectories, callback) -> ...@@ -59,7 +59,7 @@ get_files_list = (dir, onlyDirectories, callback) ->
callback(result) 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 {} socket_watchers = socket.watchers or {}
try try
watcher = socket_watchers[event_name] watcher = socket_watchers[event_name]
...@@ -75,13 +75,13 @@ watch_path_onsocket = (event_name, socket, data, watch_path, updater) -> ...@@ -75,13 +75,13 @@ watch_path_onsocket = (event_name, socket, data, watch_path, updater) ->
persistent: true, persistent: true,
(event, fileName) -> (event, fileName) ->
if event is "rename" if event is "rename"
updater(event_name, socket, data)) callback(event_name, socket, data))
else if stats.isFile() else if stats.isFile()
watcher = new Tail(watch_path) watcher = new Tail(watch_path)
watcher.on("line", (new_content, tailInfo) -> watcher.on "line", (new_content, tailInfo) ->
data.file.new_content = new_content + "\n" data.file.new_content = new_content + "\n"
updater event_name, socket, data) callback(event_name, socket, data)
watcher.on "error", (msg) -> watcher.on "error", (msg) ->
socket.emit config.events.error, msg socket.emit config.events.error, msg
...@@ -91,7 +91,7 @@ watch_path_onsocket = (event_name, socket, data, watch_path, updater) -> ...@@ -91,7 +91,7 @@ watch_path_onsocket = (event_name, socket, data, watch_path, updater) ->
catch err catch err
errors_handler("watch_path_onsocket <- " + errors_handler("watch_path_onsocket <- " +
arguments_.callee.caller.name, arguments.callee.caller.name,
err, socket) err, socket)
return return
...@@ -113,7 +113,7 @@ send_distributions = (socket) -> ...@@ -113,7 +113,7 @@ send_distributions = (socket) ->
socket.emit config.events.broadcast.distributions, distributions socket.emit config.events.broadcast.distributions, distributions
errors_handler = (from, error, socket) -> errors_handler = (from, err, socket) ->
from = "NO SOCKET: " + from unless socket from = "NO SOCKET: " + from unless socket
console.error from, err.message console.error from, err.message
socket.emit config.events.error, err.message if socket 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