Skip to content
Browse files

Fixing cradle api

  • Loading branch information...
1 parent c3c5309 commit fab44be0f82bebfdd1f86047f7eea671e649dce8 @lpetre lpetre committed
Showing with 8 additions and 9 deletions.
  1. +8 −9 server/web.js
View
17 server/web.js
@@ -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) {
@@ -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
@@ -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);
@@ -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);

0 comments on commit fab44be

Please sign in to comment.
Something went wrong with that request. Please try again.