mobiletto 1.1.14 → 1.1.17
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/util/logger.js +5 -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/util/logger.js
CHANGED
|
@@ -2,7 +2,11 @@ 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.combine(
|
|
6
|
+
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }),
|
|
7
|
+
winston.format.printf((info) => {
|
|
8
|
+
return `${info.timestamp} [${info.level.toUpperCase()}] ${info.message}`
|
|
9
|
+
})),
|
|
6
10
|
transports: process.env.MOBILETTO_LOG_FILE
|
|
7
11
|
? [ new winston.transports.File({ filename: process.env.MOBILETTO_LOG_FILE }) ]
|
|
8
12
|
: [ new winston.transports.Console() ]
|