mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 18:09:15 +00:00
fix build resource creation for completed build
This commit is contained in:
parent
25d3f48b5a
commit
fb7ef0f689
@ -31,14 +31,14 @@ exports.init = function(app, callback) {
|
||||
};
|
||||
|
||||
// create resource for build data
|
||||
var createBuildDataResource = function(build) {
|
||||
if (build.id in buildDataResourcesHash) {
|
||||
var createBuildDataResource = function(buildId) {
|
||||
if (buildId in buildDataResourcesHash) {
|
||||
return;
|
||||
}
|
||||
var buildDataResource = app.dataio.resource('build' + build.id);
|
||||
var buildDataResource = app.dataio.resource('build' + buildId);
|
||||
buildDataResource.on('connection', function(client) {
|
||||
var callback = this.async(),
|
||||
buildLogPath = getBuildLogPath(build.id);
|
||||
buildLogPath = getBuildLogPath(buildId);
|
||||
|
||||
var stream = fs.createReadStream(buildLogPath, {
|
||||
encoding: 'utf8'
|
||||
@ -60,7 +60,7 @@ exports.init = function(app, callback) {
|
||||
);
|
||||
});
|
||||
});
|
||||
buildDataResourcesHash[build.id] = buildDataResource;
|
||||
buildDataResourcesHash[buildId] = buildDataResource;
|
||||
};
|
||||
|
||||
exports.createBuildDataResource = createBuildDataResource;
|
||||
@ -73,7 +73,7 @@ exports.init = function(app, callback) {
|
||||
if (build.status === 'queued') {
|
||||
// remove prev log if it exists - for development
|
||||
fs.unlink(getBuildLogPath(build.id));
|
||||
createBuildDataResource(build);
|
||||
createBuildDataResource(build.id);
|
||||
}
|
||||
|
||||
buildsResource.clientEmitSync('change', {
|
||||
|
@ -11,7 +11,7 @@ module.exports = function(app) {
|
||||
distributor = app.distributor;
|
||||
|
||||
resource.use('createBuildDataResource', function(req, res) {
|
||||
createBuildDataResource({id: req.data.id});
|
||||
createBuildDataResource(req.data.buildId);
|
||||
res.send();
|
||||
});
|
||||
|
||||
|
@ -40,11 +40,14 @@ define([
|
||||
|
||||
// create data resource for completed build
|
||||
if (build.completed) {
|
||||
connect.resource('projects')
|
||||
.sync('createBuildDataResource', function(err) {
|
||||
connect.resource('projects').sync(
|
||||
'createBuildDataResource',
|
||||
{buildId: build.id},
|
||||
function(err) {
|
||||
if (err) throw err;
|
||||
connectToBuildDataResource();
|
||||
});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
connectToBuildDataResource();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user