mobiletto 1.1.15 → 1.1.16
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/index.js +21 -7
- package/package.json +1 -1
- package/test/api.spec.js +3 -3
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
2
|
const { Readable, Transform } = require('stream')
|
|
4
3
|
const { logger, setLogLevel: setLoggerLevel } = require('./util/logger')
|
|
5
4
|
const { getRedis, teardown } = require('./util/redis')
|
|
@@ -461,14 +460,29 @@ async function mobiletto (driverPath, key, secret, opts, encryption = null) {
|
|
|
461
460
|
|
|
462
461
|
const _loadMeta = async (dirent, entries) => {
|
|
463
462
|
const files = []
|
|
463
|
+
const promises = []
|
|
464
464
|
for (const entry of entries) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
465
|
+
promises.push(new Promise((resolve) => {
|
|
466
|
+
const cipherText = []
|
|
467
|
+
client.read(dirent + '/' + basename(entry.name), reader(cipherText))
|
|
468
|
+
.then((bytesRead) => {
|
|
469
|
+
if (!bytesRead) {
|
|
470
|
+
logger.warn(`_loadMeta(${dirent}/${basename(entry.name)}) returned no data`)
|
|
471
|
+
resolve()
|
|
472
|
+
} else {
|
|
473
|
+
const plain = decrypt(cipherText.toString(), enc)
|
|
474
|
+
const realPath = plain.split(ENC_PAD_SEP)[0]
|
|
475
|
+
_metadata(client)(realPath)
|
|
476
|
+
.then((meta) => {
|
|
477
|
+
files.push(meta)
|
|
478
|
+
resolve()
|
|
479
|
+
})
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
)
|
|
483
|
+
}))
|
|
471
484
|
}
|
|
485
|
+
await Promise.all(promises)
|
|
472
486
|
return files
|
|
473
487
|
}
|
|
474
488
|
|
package/package.json
CHANGED
package/test/api.spec.js
CHANGED
|
@@ -100,9 +100,9 @@ async function writeRandomFile(fixture, size) {
|
|
|
100
100
|
return await fixture.api.write(fixture.name, dataGenerator())
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const encryptionTests = () => [null, { key: rand(32) }]
|
|
103
|
+
// const encryptionTests = () => [null, { key: rand(32) }]
|
|
104
104
|
// const encryptionTests = () => [null]
|
|
105
|
-
|
|
105
|
+
const encryptionTests = () => [{ key: rand(32) }]
|
|
106
106
|
|
|
107
107
|
const REDIS_ENABLED = {
|
|
108
108
|
name: 'redis-enabled',
|
|
@@ -111,7 +111,7 @@ const REDIS_ENABLED = {
|
|
|
111
111
|
}
|
|
112
112
|
const REDIS_DISABLED = {
|
|
113
113
|
name: 'redis-disabled',
|
|
114
|
-
enabled:
|
|
114
|
+
enabled: false,
|
|
115
115
|
config: (cfg) => {
|
|
116
116
|
const newConfig = Object.assign({}, cfg)
|
|
117
117
|
if (!newConfig.opts) { newConfig.opts = {} }
|