mobiletto 1.1.13 → 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/drivers/s3/index.js +2 -1
- package/index.js +21 -7
- package/package.json +1 -1
- package/test/api.spec.js +3 -3
- package/util/logger.js +1 -1
package/drivers/s3/index.js
CHANGED
|
@@ -181,7 +181,8 @@ class StorageClient {
|
|
|
181
181
|
const head = await this.client.send(new HeadObjectCommand(bucketParams))
|
|
182
182
|
const meta = {
|
|
183
183
|
name: this.stripPrefix(path),
|
|
184
|
-
size: head.ContentLength
|
|
184
|
+
size: head.ContentLength,
|
|
185
|
+
type: path.endsWith(this.delimiter) ? M_DIR : M_FILE
|
|
185
186
|
}
|
|
186
187
|
if (head.LastModified) {
|
|
187
188
|
meta.mtime = Date.parse(head.LastModified)
|
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 = {} }
|
package/util/logger.js
CHANGED
|
@@ -2,7 +2,7 @@ const winston = require('winston')
|
|
|
2
2
|
|
|
3
3
|
const logger = winston.createLogger({
|
|
4
4
|
level: process.env.MOBILETTO_LOG_LEVEL || 'error',
|
|
5
|
-
format: winston.format.
|
|
5
|
+
format: winston.format.timestamp(),
|
|
6
6
|
transports: process.env.MOBILETTO_LOG_FILE
|
|
7
7
|
? [ new winston.transports.File({ filename: process.env.MOBILETTO_LOG_FILE }) ]
|
|
8
8
|
: [ new winston.transports.Console() ]
|