Commit 10ef0363 authored by Leo Iannacone's avatar Leo Iannacone

send info in the package JSON file as package status

parent d9d2976c
......@@ -62,56 +62,15 @@ function __read_package_status(data, cb) {
});
}
function __send_package_status(socket, data, package_data) {
var event_name = config.events.client.distribution_packages_status;
var new_data = {};
new_data.distribution = data.distribution;
new_data.package = package_data;
var status_data = {};
status_data.status = config.status.build;
status_data.distribution = data.distribution.name;
status_data.package = package_data.orig_name;
var package_path = utils.get_package_path(new_data);
// status policy:
// + successed: exists .dsc
// + building: wc -l .datestamp == 1 (FIX_ME)
// + failed: else
var base_path = path.join(package_path, package_data.orig_name);
fs.exists(base_path + '.dsc', function (dsc_exists) {
if (dsc_exists) {
status_data.success = config.status.success;
socket.emit(event_name, status_data);
} else {
// emulate wc -l .datestamp in nodejs
var count = 0;
var datestamp = base_path + '.datestamp';
fs.exists(datestamp, function (datestamp_exists) {
if (datestamp_exists) {
// count lines
fs.createReadStream(datestamp)
.on('data', function (chunk) {
for (var i = 0; i < chunk.length; ++i)
if (chunk[i] == 10) count++;
})
.on('end', function () {
if (count > 1)
status_data.success = config.status.fail;
socket.emit(event_name, status_data);
});
}
});
}
function __send_package_info(socket, data) {
__read_package_status(data, function (content) {
socket.emit(_e.package_info, content);
});
}
function __send_package_info(socket, data) {
function __send_package_status(socket, data) {
__read_package_status(data, function (content) {
socket.emit(_e.package_info, content);
socket.emit(_e.distribution_packages_status, content);
});
}
......@@ -125,8 +84,11 @@ function __send_distribution_packages(event_name, socket, data) {
pack.name = info[0];
pack.version = info[1];
pack.orig_name = p;
__send_package_status(socket, {
distribution: data.distribution,
package: pack
});
data.distribution.packages.push(pack);
__send_package_status(socket, data, pack);
});
socket.emit(event_name, data);
});
......
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