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.
@@ -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
- const cipherText = []
466
- await client.read(dirent + '/' + basename(entry.name), reader(cipherText))
467
- const plain = decrypt(cipherText.toString(), enc)
468
- const realPath = plain.split(ENC_PAD_SEP)[0]
469
- const meta = await _metadata(client)(realPath)
470
- files.push(meta)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobiletto",
3
- "version": "1.1.14",
3
+ "version": "1.1.17",
4
4
  "description": "A storage layer that presents a uniform interface to Amazon S3, Backblaze B2, and local storage",
5
5
  "main": "index.js",
6
6
  "keywords": [
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.timestamp(),
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() ]