From 64b4efef17b053a7475ebb0dbdd07415346ce829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 12 Sep 2019 17:23:19 +0200 Subject: [PATCH] Do not cache map template CRUD errors in Named Map provider --- .../mapconfig/provider/named-map-provider.js | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/lib/cartodb/models/mapconfig/provider/named-map-provider.js b/lib/cartodb/models/mapconfig/provider/named-map-provider.js index 298920a1..292e5dcb 100644 --- a/lib/cartodb/models/mapconfig/provider/named-map-provider.js +++ b/lib/cartodb/models/mapconfig/provider/named-map-provider.js @@ -48,7 +48,6 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { this.affectedTablesCache = affectedTablesCache; // providing - this.err = null; this.mapConfig = null; this.rendererParams = null; this.context = {}; @@ -56,13 +55,12 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { } getMapConfig (callback) { - if (!!this.err || this.mapConfig !== null) { - return callback(this.err, this.mapConfig, this.rendererParams, this.context); + if (this.mapConfig !== null) { + return callback(null, this.mapConfig, this.rendererParams, this.context); } this.getContext((err, context) => { if (err) { - this.err = err; return callback(err); } @@ -75,8 +73,6 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { this.config; } catch (e) { const err = new Error('malformed config parameter, should be a valid JSON'); - this.err = err; - return callback(err); } } @@ -85,7 +81,6 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { this.getTemplate((err, template) => { if (err) { - this.err = err; return callback(err); } @@ -94,7 +89,6 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { try { requestMapConfig = this.templateMaps.instance(template, templateParams); } catch (err) { - this.err = err; return callback(err); } @@ -103,7 +97,6 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { this.mapConfigAdapter.getMapConfig( user, requestMapConfig, rendererParams, context, (err, mapConfig, stats = {}) => { if (err) { - this.err = err; return callback(err); } @@ -148,7 +141,6 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { this.userLimitsBackend.getRenderLimits(this.user, this.params.api_key, (err, renderLimits) => { if (err) { - this.err = err; return callback(err); } @@ -163,13 +155,12 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { } getTemplate (callback) { - if (!!this.err || this.template !== null) { - return callback(this.err, this.template); + if (this.template !== null) { + return callback(null, this.template); } this.templateMaps.getTemplate(this.user, this.templateName, (err, tpl) => { if (err) { - this.err = err; return callback(err); } @@ -177,8 +168,6 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { const error = new Error(`Template '${this.templateName}' of user '${this.user}' not found`); error.http_status = 404; - this.err = error; - return callback(error); } @@ -190,15 +179,12 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { const error = new Error('Failed to authorize template'); error.http_status = 403; - this.err = error; - return callback(error); } if (!authorized) { const error = new Error('Unauthorized template instantiation'); error.http_status = 403; - this.err = error; return callback(error); } @@ -222,7 +208,6 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider { this.affectedTables = null; - this.err = null; this.mapConfig = null; this.cacheBuster = Date.now();