Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Fixing cradle api
Browse files Browse the repository at this point in the history
  • Loading branch information
lpetre committed Mar 22, 2012
1 parent c3c5309 commit fab44be
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions server/web.js
Expand Up @@ -26,7 +26,7 @@ var couchdb_options = couchdb_url.auth ?
{ auth: { username: couchdb_url.auth.split(':')[0], password: couchdb_url.auth.split(':')[1] } } :
{ }
var db = new(cradle.Connection)(couchdb_url.hostname, couchdb_url.port || 5984, couchdb_options).database('make');
db.create();
db.create(function(){});

// POST /make starts a build
app.post('/make', function(request, response, next) {
Expand Down Expand Up @@ -61,12 +61,11 @@ app.post('/make', function(request, response, next) {

// save the input tarball as an attachment
log_action(id, 'saving attachment - [id:' + doc.id + ', rev:' + doc.rev + ']')
db.saveAttachment(
doc.id,
doc.rev,
'input',
'application/octet-stream',
fs.createReadStream(files.code.path),
fs.createReadStream(files.code.path).pipe(db.saveAttachment(
{id: doc.id,
rev: doc.rev},
{name:'input',
'Content-Type': 'application/octet-stream'},
function(err, data) {
if (err) {
// work around temporary problem with cloudant and document
Expand Down Expand Up @@ -99,7 +98,7 @@ app.post('/make', function(request, response, next) {
response.end();
});
}
);
));

// return the build id as a header
response.header('X-Make-Id', id);
Expand All @@ -114,7 +113,7 @@ app.post('/make', function(request, response, next) {
app.get('/output/:id', function(request, response, next) {

// from couchdb
var stream = db.getAttachment(request.params.id, 'output');
var stream = db.getAttachment(request.params.id, 'output', function(){});

stream.on('error', function(err) {
console.log('download error: ' + err);
Expand Down

0 comments on commit fab44be

Please sign in to comment.