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.
@@ -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.13",
3
+ "version": "1.1.16",
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/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
- // const encryptionTests = () => [{ key: rand(32) }]
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: true,
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.simple(),
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() ]