pixl-server-storage 3.0.14 → 3.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/engines/S3.js +23 -13
- package/package.json +1 -1
- package/storage.js +9 -5
package/engines/S3.js
CHANGED
|
@@ -127,7 +127,7 @@ module.exports = Class.create({
|
|
|
127
127
|
if (done) return; else done = true;
|
|
128
128
|
|
|
129
129
|
if (err) {
|
|
130
|
-
self.logError('s3', "Failed to store object: " + key + ": " + err.message);
|
|
130
|
+
self.logError('s3', "Failed to store object: " + key + ": " + (err.message || err), err);
|
|
131
131
|
}
|
|
132
132
|
else self.logDebug(9, "Store complete: " + key);
|
|
133
133
|
|
|
@@ -158,7 +158,7 @@ module.exports = Class.create({
|
|
|
158
158
|
if (done) return; else done = true;
|
|
159
159
|
|
|
160
160
|
if (err) {
|
|
161
|
-
self.logError('s3', "Failed to store stream: " + key + ": " + err.message);
|
|
161
|
+
self.logError('s3', "Failed to store stream: " + key + ": " + (err.message || err), err);
|
|
162
162
|
}
|
|
163
163
|
else self.logDebug(9, "Stream store complete: " + key);
|
|
164
164
|
|
|
@@ -193,8 +193,15 @@ module.exports = Class.create({
|
|
|
193
193
|
if (done) return; else done = true;
|
|
194
194
|
|
|
195
195
|
if (err) {
|
|
196
|
-
if (err.code
|
|
197
|
-
|
|
196
|
+
if ((err.code == 'NoSuchKey') || (err.code == 'NotFound')) {
|
|
197
|
+
// key not found, special case, don't log an error
|
|
198
|
+
// always include "Not found" in error message
|
|
199
|
+
err = new Error("Failed to head key: " + key + ": Not found");
|
|
200
|
+
err.code = "NoSuchKey";
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
// some other error
|
|
204
|
+
self.logError('s3', "Failed to head key: " + key + ": " + (err.message || err), err);
|
|
198
205
|
}
|
|
199
206
|
callback( err, null );
|
|
200
207
|
return;
|
|
@@ -249,7 +256,7 @@ module.exports = Class.create({
|
|
|
249
256
|
}
|
|
250
257
|
else {
|
|
251
258
|
// some other error
|
|
252
|
-
self.logError('s3', "Failed to fetch key: " + key + ": " + err.message);
|
|
259
|
+
self.logError('s3', "Failed to fetch key: " + key + ": " + (err.message || err), err);
|
|
253
260
|
}
|
|
254
261
|
callback( err, null );
|
|
255
262
|
return;
|
|
@@ -277,7 +284,10 @@ module.exports = Class.create({
|
|
|
277
284
|
self.logDebug(9, "JSON fetch complete: " + key, self.debugLevel(10) ? body : null);
|
|
278
285
|
}
|
|
279
286
|
|
|
280
|
-
callback( null, body
|
|
287
|
+
callback( null, body, {
|
|
288
|
+
mod: Math.floor((new Date(data.LastModified)).getTime() / 1000),
|
|
289
|
+
len: data.ContentLength
|
|
290
|
+
} );
|
|
281
291
|
} );
|
|
282
292
|
},
|
|
283
293
|
|
|
@@ -294,7 +304,7 @@ module.exports = Class.create({
|
|
|
294
304
|
var proceed = false;
|
|
295
305
|
|
|
296
306
|
download.on('error', function(err) {
|
|
297
|
-
if (proceed) self.logError('s3', "Failed to download key: " + key + ": " + err.message);
|
|
307
|
+
if (proceed) self.logError('s3', "Failed to download key: " + key + ": " + (err.message || err), err);
|
|
298
308
|
});
|
|
299
309
|
download.once('end', function() {
|
|
300
310
|
self.logDebug(9, "S3 stream download complete: " + key);
|
|
@@ -309,8 +319,8 @@ module.exports = Class.create({
|
|
|
309
319
|
if (done) return; else done = true;
|
|
310
320
|
|
|
311
321
|
if (err) {
|
|
312
|
-
if (err.code != 'NoSuchKey') {
|
|
313
|
-
self.logError('s3', "Failed to head key: " + key + ": " + err.message);
|
|
322
|
+
if ((err.code != 'NoSuchKey') && (err.code != 'NotFound')) {
|
|
323
|
+
self.logError('s3', "Failed to head key: " + key + ": " + (err.message || err), err);
|
|
314
324
|
}
|
|
315
325
|
download.destroy();
|
|
316
326
|
callback( err, null );
|
|
@@ -345,7 +355,7 @@ module.exports = Class.create({
|
|
|
345
355
|
var proceed = false;
|
|
346
356
|
|
|
347
357
|
download.on('error', function(err) {
|
|
348
|
-
if (proceed) self.logError('s3', "Failed to download key: " + key + ": " + err.message);
|
|
358
|
+
if (proceed) self.logError('s3', "Failed to download key: " + key + ": " + (err.message || err), err);
|
|
349
359
|
});
|
|
350
360
|
download.once('end', function() {
|
|
351
361
|
self.logDebug(9, "S3 stream download complete: " + key);
|
|
@@ -360,8 +370,8 @@ module.exports = Class.create({
|
|
|
360
370
|
if (done) return; else done = true;
|
|
361
371
|
|
|
362
372
|
if (err) {
|
|
363
|
-
if (err.code != 'NoSuchKey') {
|
|
364
|
-
self.logError('s3', "Failed to head key: " + key + ": " + err.message);
|
|
373
|
+
if ((err.code != 'NoSuchKey') && (err.code != 'NotFound')) {
|
|
374
|
+
self.logError('s3', "Failed to head key: " + key + ": " + (err.message || err), err);
|
|
365
375
|
}
|
|
366
376
|
download.destroy();
|
|
367
377
|
callback( err, null );
|
|
@@ -404,7 +414,7 @@ module.exports = Class.create({
|
|
|
404
414
|
if (done) return; else done = true;
|
|
405
415
|
|
|
406
416
|
if (err) {
|
|
407
|
-
self.logError('s3', "Failed to delete object: " + key + ": " + err.message);
|
|
417
|
+
self.logError('s3', "Failed to delete object: " + key + ": " + (err.message || err), err);
|
|
408
418
|
}
|
|
409
419
|
else self.logDebug(9, "Delete complete: " + key);
|
|
410
420
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixl-server-storage",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.18",
|
|
4
4
|
"description": "A key/value/list storage component for the pixl-server framework.",
|
|
5
5
|
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/jhuckaby/pixl-server-storage",
|
package/storage.js
CHANGED
|
@@ -34,7 +34,8 @@ module.exports = Class.create({
|
|
|
34
34
|
},
|
|
35
35
|
max_recent_events: 0,
|
|
36
36
|
cache_key_match: '',
|
|
37
|
-
expiration_updates: false
|
|
37
|
+
expiration_updates: false,
|
|
38
|
+
lower_case_keys: true
|
|
38
39
|
},
|
|
39
40
|
|
|
40
41
|
locks: null,
|
|
@@ -130,6 +131,7 @@ module.exports = Class.create({
|
|
|
130
131
|
this.logEventTypes = this.config.get('log_event_types');
|
|
131
132
|
this.maxRecentEvents = this.config.get('max_recent_events');
|
|
132
133
|
this.expHash = this.config.get('expiration_updates');
|
|
134
|
+
this.lowerKeys = this.config.get('lower_case_keys');
|
|
133
135
|
|
|
134
136
|
this.cacheKeyRegex = null;
|
|
135
137
|
if (this.config.get('cache_key_match')) {
|
|
@@ -139,7 +141,9 @@ module.exports = Class.create({
|
|
|
139
141
|
|
|
140
142
|
normalizeKey: function(key) {
|
|
141
143
|
// downconvert unicode, lower-case, alphanum-dash-dot-slash only, strip leading and trailing slashes
|
|
142
|
-
|
|
144
|
+
key = '' + key;
|
|
145
|
+
if (this.lowerKeys) key = key.toLowerCase();
|
|
146
|
+
return unidecode(key).replace(/[^\w\-\.\/]+/g, '').replace(/\/+/g, '/').replace(/^\//, '').replace(/\/$/, '');
|
|
143
147
|
},
|
|
144
148
|
|
|
145
149
|
isBinaryKey: function(key) {
|
|
@@ -320,7 +324,7 @@ module.exports = Class.create({
|
|
|
320
324
|
// invoke engine and track perf
|
|
321
325
|
var pf = this.perf.begin('get');
|
|
322
326
|
|
|
323
|
-
this.engine.get( key, function(err, value) {
|
|
327
|
+
this.engine.get( key, function(err, value, info) {
|
|
324
328
|
// get complete
|
|
325
329
|
var elapsed = pf.end();
|
|
326
330
|
|
|
@@ -335,8 +339,8 @@ module.exports = Class.create({
|
|
|
335
339
|
elapsed_ms: elapsed
|
|
336
340
|
});
|
|
337
341
|
|
|
338
|
-
callback(null, value);
|
|
339
|
-
if (!err) self.emit('get', key, value);
|
|
342
|
+
callback(null, value, info);
|
|
343
|
+
if (!err) self.emit('get', key, value, info);
|
|
340
344
|
} );
|
|
341
345
|
},
|
|
342
346
|
|