pixl-server-storage 3.1.10 → 3.1.12

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.
@@ -376,8 +376,9 @@ module.exports = Class.create({
376
376
 
377
377
  // check cache first
378
378
  if (this.cache && this.cache.has(key)) {
379
+ var item = this.cache.getMeta(key);
380
+
379
381
  process.nextTick( function() {
380
- var item = self.cache.getMeta(key);
381
382
  self.logDebug(9, "Cached head complete: " + key);
382
383
  callback( null, {
383
384
  mod: item.date,
@@ -420,9 +421,9 @@ module.exports = Class.create({
420
421
 
421
422
  // check cache first
422
423
  if (this.cache && !is_binary && this.cache.has(key)) {
424
+ var data = this.cache.get(key);
425
+
423
426
  process.nextTick( function() {
424
- var data = self.cache.get(key);
425
-
426
427
  try { data = JSON.parse( data ); }
427
428
  catch (e) {
428
429
  self.logError('file', "Failed to parse JSON record: " + key + ": " + e);
package/engines/S3.js CHANGED
@@ -8,7 +8,7 @@ var Tools = require("pixl-tools");
8
8
  var Cache = require("pixl-cache");
9
9
  var S3 = require("@aws-sdk/client-s3");
10
10
  var { Upload } = require("@aws-sdk/lib-storage");
11
- var { NodeHttpHandler } = require("@aws-sdk/node-http-handler");
11
+ var { NodeHttpHandler } = require("@smithy/node-http-handler");
12
12
  var streamToBuffer = require("fast-stream-to-buffer");
13
13
 
14
14
  module.exports = Class.create({
@@ -234,8 +234,9 @@ module.exports = Class.create({
234
234
 
235
235
  // check cache first
236
236
  if (this.cache && this.cache.has(orig_key)) {
237
+ var item = this.cache.getMeta(orig_key);
238
+
237
239
  process.nextTick( function() {
238
- var item = self.cache.getMeta(orig_key);
239
240
  self.logDebug(9, "Cached head complete: " + orig_key);
240
241
  callback( null, {
241
242
  mod: item.date,
@@ -285,9 +286,9 @@ module.exports = Class.create({
285
286
 
286
287
  // check cache first
287
288
  if (this.cache && !is_binary && this.cache.has(orig_key)) {
288
- process.nextTick( function() {
289
- var data = self.cache.get(orig_key);
290
-
289
+ var data = this.cache.get(orig_key);
290
+
291
+ process.nextTick( function() {
291
292
  try { data = JSON.parse( data ); }
292
293
  catch (e) {
293
294
  self.logError('file', "Failed to parse JSON record: " + orig_key + ": " + e);
package/hash.js CHANGED
@@ -79,12 +79,12 @@ module.exports = Class.create({
79
79
  _hashShareLock: function(key, wait, callback) {
80
80
  // internal hash shared lock wrapper
81
81
  // uses unique key prefix so won't deadlock with user locks
82
- this.shareLock( '|'+key, wait, callback );
82
+ this.shareLock( 'C|'+key, wait, callback );
83
83
  },
84
84
 
85
85
  _hashShareUnlock: function(key) {
86
86
  // internal hash shared unlock wrapper
87
- this.shareUnlock( '|'+key );
87
+ this.shareUnlock( 'C|'+key );
88
88
  },
89
89
 
90
90
  hashPut: function(path, hkey, hvalue, create_opts, callback) {
package/list.js CHANGED
@@ -111,12 +111,12 @@ module.exports = Class.create({
111
111
  _listShareLock: function(key, wait, callback) {
112
112
  // internal list shared lock wrapper
113
113
  // uses unique key prefix so won't deadlock with user locks
114
- this.shareLock( '|'+key, wait, callback );
114
+ this.shareLock( 'C|'+key, wait, callback );
115
115
  },
116
116
 
117
117
  _listShareUnlock: function(key) {
118
118
  // internal list shared unlock wrapper
119
- this.shareUnlock( '|'+key );
119
+ this.shareUnlock( 'C|'+key );
120
120
  },
121
121
 
122
122
  listPush: function(key, items, create_opts, callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixl-server-storage",
3
- "version": "3.1.10",
3
+ "version": "3.1.12",
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",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@aws-sdk/client-s3": "3.374.0",
26
26
  "@aws-sdk/lib-storage": "3.374.0",
27
- "@aws-sdk/node-http-handler": "3.374.0",
27
+ "@smithy/node-http-handler": "2.0.1",
28
28
  "async": "2.6.4",
29
29
  "fast-stream-to-buffer": "1.0.0",
30
30
  "he": "1.1.1",
package/test/config.json CHANGED
@@ -26,17 +26,16 @@
26
26
  }
27
27
  },
28
28
  "AWS": {
29
- "accessKeyId": "YOUR_AMAZON_ACCESS_KEY",
30
- "secretAccessKey": "YOUR_AMAZON_SECRET_KEY",
31
29
  "region": "us-west-1",
32
- "correctClockSkew": true,
33
- "maxRetries": 5,
34
- "httpOptions": {
35
- "connectTimeout": 5000,
36
- "timeout": 5000
30
+ "credentials": {
31
+ "accessKeyId": "YOUR_AMAZON_ACCESS_KEY",
32
+ "secretAccessKey": "YOUR_AMAZON_SECRET_KEY"
37
33
  }
38
34
  },
39
35
  "S3": {
36
+ "connectTimeout": 5000,
37
+ "socketTimeout": 5000,
38
+ "maxAttempts": 50,
40
39
  "keyPrefix": "",
41
40
  "fileExtensions": true,
42
41
  "params": {
package/transaction.js CHANGED
@@ -735,10 +735,13 @@ module.exports = Class.create({
735
735
  } );
736
736
  },
737
737
  function(callback) {
738
+ // notify listeners that the commit is starting, and the rollback log is available
739
+ self.emit('commitStart', trans);
740
+
738
741
  // We must fsync the directory as well, as per: http://man7.org/linux/man-pages/man2/fsync.2.html
739
742
  // Note: Yes, read-only is the only way: https://www.reddit.com/r/node/comments/4r8k11/how_to_call_fsync_on_a_directory/
740
743
  fs.open( Path.dirname(trans.log), "r", function(err, dh) {
741
- if (err) return callback(err);
744
+ if (err) return callback(); // this may fail on certain OSes, so treat as non-fatal
742
745
 
743
746
  fs.fsync(dh, function(err) {
744
747
  // ignoring error here, as some filesystems may not allow this
@@ -784,6 +787,7 @@ module.exports = Class.create({
784
787
  if (err) {
785
788
  var msg = "Failed to commit transaction: " + path + ": " + err.message;
786
789
  self.logError('commit', msg, { id: trans.id });
790
+ self.emit('commitEnd', trans, err);
787
791
  return callback( new Error(msg) );
788
792
  }
789
793
 
@@ -819,6 +823,7 @@ module.exports = Class.create({
819
823
  delete trans.keys; // release memory
820
824
  }
821
825
 
826
+ self.emit('commitEnd', trans);
822
827
  self.unlock( 'C|'+path );
823
828
  self._transUnlock(path);
824
829
  callback();