Commit 8fe66560 authored by Leo Iannacone's avatar Leo Iannacone

check if distribution directory has pool subdir, which means is real a distribution directory

parent 4179b71c
......@@ -50,9 +50,7 @@ function __watch_build_status (socket, status) {
// watcher on new distributions
function __watch_distributions (socket) {
fs.watch(config.debomatic.path, { persistent: true }, function (event, fileName) {
utils.get_files_list(config.debomatic.path, true, function(distros) {
socket.emit(config.events.broadcast.distributions, distros);
})
utils.send_distributions(socket)
})
}
......
......@@ -137,10 +137,8 @@ function Client (socket) {
var socket = socket
this.start = function () {
// init send distributions and status
utils.get_files_list(config.debomatic.path, true, function(distros) {
socket.emit(config.events.broadcast.distributions, distros);
})
// init send distributions
utils.send_distributions(socket)
// init events
socket.on(_e.distribution_packages.get, function (data) {
......
......@@ -84,7 +84,7 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) {
fs.stat(watch_path, function(err, stats) {
if (err) {
utils.errors_handler("__watch_path_onsocket:fs.stat", err, socket)
__errors_handler("__watch_path_onsocket:fs.stat", err, socket)
return
}
if (stats.isDirectory()) {
......@@ -114,6 +114,22 @@ function __generic_handler_watcher(event_name, socket, data, watch_path, callbac
callback(event_name, socket, data)
}
function __send_distributions(socket) {
__get_files_list(config.debomatic.path, true, function(directories) {
var distributions = []
directories.forEach(function(dir) {
var data = {}
data.distribution = {}
data.distribution.name = dir
var pool_path = __get_distribution_pool_path(data)
if (fs.existsSync(pool_path)) {
distributions.push(dir)
}
})
socket.emit(config.events.broadcast.distributions, distributions);
})
}
utils = {
check_data_distribution: function(data) {
return __check_data_distribution(data)
......@@ -142,6 +158,9 @@ utils = {
generic_handler_watcher: function(event_name, socket, data, watch_path, callback) {
return __generic_handler_watcher(event_name, socket, data, watch_path, callback);
},
send_distributions: function(socket) {
return __send_distributions(socket)
},
errors_handler: function(from, error, socket) {
return __errors_handler(from, error, 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