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