diff --git a/NEWS.md b/NEWS.md index dce0365d..de39e8d2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,9 @@ 1.4.0 ----- * Add arraybuffer format +* Fix filesystem access conflict among clustered processes +* Fix discard of queued export requests on error +* Really fix problem identifying OAuth requests 1.3.10 ------ diff --git a/app.js b/app.js index 96c37f49..9b9db8ab 100755 --- a/app.js +++ b/app.js @@ -13,9 +13,9 @@ var _ = require('underscore'); // sanity check arguments var ENV = process.argv[2]; -if (ENV != 'development' && ENV != 'production' && ENV != 'test') { +if (ENV != 'development' && ENV != 'production' && ENV != 'test' && ENV != 'staging' ) { console.error("\n./app [environment]"); - console.error("environments: [development, test, production]"); + console.error("environments: [development, staging, production, test]"); process.exit(1); } diff --git a/app/models/formats/ogr.js b/app/models/formats/ogr.js index ac58e723..7d7e0d78 100644 --- a/app/models/formats/ogr.js +++ b/app/models/formats/ogr.js @@ -160,7 +160,7 @@ console.log(['ogr2ogr', ogr.prototype.toOGR_SingleFile = function(dbname, user_id, gcol, sql, skipfields, fmt, ext, callback) { var tmpdir = global.settings.tmpDir || '/tmp'; var reqKey = [ fmt, dbname, user_id, gcol, this.generateMD5(sql) ].concat(skipfields).join(':'); - var outdirpath = tmpdir + '/sqlapi-' + reqKey; + var outdirpath = tmpdir + '/sqlapi-' + process.pid + '-' + reqKey; var dumpfile = outdirpath + ':cartodb-query.' + ext; // TODO: following tests: @@ -178,12 +178,8 @@ ogr.prototype.sendResponse = function(opts, callback) { } else { baking = bakingExports[reqKey] = { req: [ qElem ] }; this.generate(opts, function(err, dumpfile) { - if(err) { - next(err); - return; - } Step ( - function sendResults(err) { + function sendResults() { var nextPipe = function(finish) { var r = baking.req.shift(); if ( ! r ) { finish(null); return; } diff --git a/app/models/formats/shp.js b/app/models/formats/shp.js index 7e48d82a..8e81621d 100644 --- a/app/models/formats/shp.js +++ b/app/models/formats/shp.js @@ -25,7 +25,7 @@ p.toSHP = function (dbname, user_id, gcol, sql, skipfields, filename, callback) var zip = 'zip'; // FIXME: make configurable var tmpdir = global.settings.tmpDir || '/tmp'; var reqKey = [ 'shp', dbname, user_id, gcol, this.generateMD5(sql) ].concat(skipfields).join(':'); - var outdirpath = tmpdir + '/sqlapi-' + reqKey; + var outdirpath = tmpdir + '/sqlapi-' + process.pid + '-' + reqKey; var zipfile = outdirpath + '.zip'; var shapefile = outdirpath + '/' + filename + '.shp'; @@ -87,11 +87,14 @@ p.toSHP = function (dbname, user_id, gcol, sql, skipfields, filename, callback) unlinkall(outdirpath, files, function(err) { fs.rmdir(outdirpath, function(err) { if ( err ) console.log("Removing dir " + path + ": " + err); - callback(topError, zipfile); + next(topError, zipfile); }); }); } }); + }, + function finalStep(err, zipfile) { + callback(err, zipfile); } ); }; diff --git a/app/models/oauth.js b/app/models/oauth.js index 35a30502..5ed2621a 100644 --- a/app/models/oauth.js +++ b/app/models/oauth.js @@ -108,7 +108,7 @@ var oAuth = function(){ return; } - var path = httpProto + '://' + host + req.route.path; + var path = httpProto + '://' + host + req.path; that.splitParams(req.query); // remove signature from passed_tokens