Merge pull request #681 from CartoDB/feature/ch139802/phl-inconsistent-errors-when-downloading

[ch139802] Avoid concurrent requests from getting stuck when exporting file formats handled by OGR - v2
This commit is contained in:
Shylpx 2021-03-29 18:37:28 +01:00 committed by GitHub
commit 248c98bc83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
'use strict'; 'use strict';
var uuid = require('uuid');
var step = require('step'); var step = require('step');
var fs = require('fs'); var fs = require('fs');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
@ -37,7 +38,7 @@ ShpFormat.prototype.toSHP = function (options, callback) {
var zip = global.settings.zipCommand || 'zip'; var zip = global.settings.zipCommand || 'zip';
var zipOptions = '-qrj'; var zipOptions = '-qrj';
var tmpdir = global.settings.tmpDir || '/tmp'; var tmpdir = global.settings.tmpDir || '/tmp';
var reqKey = this.limitPathname(['shp', dbname, userId, gcol, this.generateMD5(sql)].concat(skipfields).join(':')); var reqKey = this.limitPathname(['shp', dbname, userId, gcol, this.generateMD5(sql), uuid.v4()].concat(skipfields).join(':'));
var outdirpath = tmpdir + '/sqlapi-' + process.pid + '-' + reqKey; var outdirpath = tmpdir + '/sqlapi-' + process.pid + '-' + reqKey;
var zipfile = outdirpath + '.zip'; var zipfile = outdirpath + '.zip';
var shapefile = outdirpath + '/' + filename + '.shp'; var shapefile = outdirpath + '/' + filename + '.shp';