Commit 1cb0763d authored by Leo Iannacone's avatar Leo Iannacone

moved generic_handler to utils

parent 359d06e7
...@@ -77,11 +77,6 @@ function __send_distributions(event_name, socket, data) { ...@@ -77,11 +77,6 @@ function __send_distributions(event_name, socket, data) {
}); });
} }
function __generic_handler(event_name, socket, data, watch_path, callback) {
utils.watch_path_onsocket(event_name, socket, data, config.debomatic.path, callback)
callback(event_name, socket, data)
}
function __handler_get_file (socket, data) { function __handler_get_file (socket, data) {
file_path = utils.get_file_path(data) file_path = utils.get_file_path(data)
utils.watch_path_onsocket('file_newcontent', socket, data, file_path, __handler_file_newcontent) utils.watch_path_onsocket('file_newcontent', socket, data, file_path, __handler_file_newcontent)
...@@ -97,20 +92,20 @@ function __handler_file_newcontent(event_name, socket, data) { ...@@ -97,20 +92,20 @@ function __handler_file_newcontent(event_name, socket, data) {
Client = function (socket) { Client = function (socket) {
__generic_handler('distributions', socket, null, config.debomatic.path, __send_distributions) utils.generic_handler_watcher('distributions', socket, null, config.debomatic.path, __send_distributions)
socket.on('get_distribution_packages', function (data) { socket.on('get_distribution_packages', function (data) {
if (! utils.check_data_distribution(data)) if (! utils.check_data_distribution(data))
return return
distribution_path = path.join(config.debomatic.path, data.distribution.name, 'pool') distribution_path = path.join(config.debomatic.path, data.distribution.name, 'pool')
__generic_handler('distribution_packages', socket, data, distribution_path, __send_distribution_packages) utils.generic_handler_watcher('distribution_packages', socket, data, distribution_path, __send_distribution_packages)
}) })
socket.on('get_package_files_list', function(data) { socket.on('get_package_files_list', function(data) {
if (! utils.check_data_package(data)) if (! utils.check_data_package(data))
return return
package_path = utils.get_package_path(data) package_path = utils.get_package_path(data)
__generic_handler('package_files_list', socket, data, package_path, __send_package_files_list) utils.generic_handler_watcher('package_files_list', socket, data, package_path, __send_package_files_list)
}) })
socket.on('get_file', function (data){ socket.on('get_file', function (data){
......
...@@ -86,6 +86,11 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) { ...@@ -86,6 +86,11 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) {
}) })
} }
function __generic_handler_watcher(event_name, socket, data, watch_path, callback) {
__watch_path_onsocket(event_name, socket, data, config.debomatic.path, callback)
callback(event_name, socket, data)
}
utils = { utils = {
check_data_distribution: function(data) { check_data_distribution: function(data) {
return __check_data_distribution(data) return __check_data_distribution(data)
...@@ -110,7 +115,11 @@ utils = { ...@@ -110,7 +115,11 @@ utils = {
}, },
watch_path_onsocket: function(event_name, socket, data, watch_path, updater) { watch_path_onsocket: function(event_name, socket, data, watch_path, updater) {
return __watch_path_onsocket(event_name, socket, data, watch_path, updater) return __watch_path_onsocket(event_name, socket, data, watch_path, updater)
},
generic_handler_watcher: function(event_name, socket, data, watch_path, callback) {
return __generic_handler_watcher(event_name, socket, data, watch_path, callback);
} }
} }
module.exports = utils module.exports = utils
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