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