mobiletto 1.0.36 → 1.0.39
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/README.md +4 -3
- package/index.js +6 -5
- package/package.json +1 -1
- package/test/index.spec.js +14 -1
package/README.md
CHANGED
|
@@ -315,11 +315,13 @@ Logs **will** contain file paths and error messages, but will **never** contain
|
|
|
315
315
|
or any other connection configuration information.
|
|
316
316
|
|
|
317
317
|
### Log level
|
|
318
|
-
Use the `MOBILETTO_LOG_LEVEL` environment variable to set the log level
|
|
318
|
+
Use the `MOBILETTO_LOG_LEVEL` environment variable to set the log level, using one
|
|
319
|
+
of the `npm` levels defined in [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
|
|
320
|
+
|
|
319
321
|
The default level is `warn`. The most verbose level is `silly`, although currently mobiletto
|
|
320
322
|
does not log at levels below `debug`
|
|
321
323
|
|
|
322
|
-
MOBILETTO_LOG_LEVEL=silly
|
|
324
|
+
MOBILETTO_LOG_LEVEL=silly # maximum logs!
|
|
323
325
|
|
|
324
326
|
### Log file
|
|
325
327
|
By default, the logger writes to the console. To send logs to a file, set the `MOBILETTO_LOG_FILE`
|
|
@@ -330,4 +332,3 @@ environment variable. When logging to a file, logs will no longer be written to
|
|
|
330
332
|
To turn off logging:
|
|
331
333
|
|
|
332
334
|
MOBILETTO_LOG_FILE=/dev/null
|
|
333
|
-
MOBILETTO_LOG_LEVEL=emerg # not strictly necessary; minimizes time spent in logging code
|
package/index.js
CHANGED
|
@@ -348,18 +348,19 @@ async function mobiletto (driverPath, key, secret, opts, encryption = null) {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
const encClient = {
|
|
351
|
-
list: async (pth, recursive, visitor) => {
|
|
352
|
-
const
|
|
351
|
+
list: async (pth = '', recursive, visitor) => {
|
|
352
|
+
const p = pth === '' ? '.' : pth.endsWith('/') ? pth.substring(0, pth.length - 1) : pth
|
|
353
|
+
const dirent = direntDir(p)
|
|
353
354
|
let entries
|
|
354
355
|
try {
|
|
355
356
|
entries = await client.list(dirent, recursive)
|
|
356
357
|
} catch (e) {
|
|
357
|
-
if (e instanceof MobilettoNotFoundError) {
|
|
358
|
+
if (e instanceof MobilettoNotFoundError && p.includes('/')) {
|
|
358
359
|
// it might be a single file, try listing the parent dir
|
|
359
|
-
const parentDirent = direntDir(path.dirname(
|
|
360
|
+
const parentDirent = direntDir(path.dirname(p));
|
|
360
361
|
entries = await client.list(parentDirent, false)
|
|
361
362
|
const objects = await _loadMeta(parentDirent, entries)
|
|
362
|
-
const found = objects.find(o => o.name ===
|
|
363
|
+
const found = objects.find(o => o.name === p)
|
|
363
364
|
if (found) {
|
|
364
365
|
return [ found ]
|
|
365
366
|
}
|
package/package.json
CHANGED
package/test/index.spec.js
CHANGED
|
@@ -167,7 +167,7 @@ for (const driverName of DRIVER_NAMES) {
|
|
|
167
167
|
const encDesc = encryption ? '(with encryption)' : '(without encryption)'
|
|
168
168
|
describe(`${driverName} - ${encDesc} fail to write and delete files in readOnly mode`, () => {
|
|
169
169
|
// describe(`${driverName} - ENC fail to write and delete files in readOnly mode`, () => {
|
|
170
|
-
|
|
170
|
+
// const encryption = {key: rand(32)}
|
|
171
171
|
const size = 16
|
|
172
172
|
const randomData = rand(size)
|
|
173
173
|
const fileSuffix = '' + Date.now()
|
|
@@ -305,6 +305,19 @@ for (const driverName of DRIVER_NAMES) {
|
|
|
305
305
|
expect(singleFile).to.have.lengthOf(1)
|
|
306
306
|
expect(singleFile[0]).to.have.property('name', fixture.name)
|
|
307
307
|
})
|
|
308
|
+
it("should successfully list files in the base directory", async () => {
|
|
309
|
+
const baseListing = await fixture.api.list()
|
|
310
|
+
expect(baseListing).to.have.lengthOf.greaterThanOrEqual(1)
|
|
311
|
+
expect(baseListing.find(o => o.name === path.dirname(randomParent))).to.not.be.null
|
|
312
|
+
})
|
|
313
|
+
it("should successfully list files in a subdirectory", async () => {
|
|
314
|
+
const listing = await fixture.api.list(randomParent)
|
|
315
|
+
expect(listing).to.have.lengthOf.greaterThanOrEqual(1)
|
|
316
|
+
})
|
|
317
|
+
it("should successfully list files in a subdirectory ending with a slash", async () => {
|
|
318
|
+
const listing = await fixture.api.list(randomParent+'/')
|
|
319
|
+
expect(listing).to.have.lengthOf.greaterThanOrEqual(1)
|
|
320
|
+
})
|
|
308
321
|
it("should load metadata for one of the new files", async () => {
|
|
309
322
|
await assertMeta(fixture.api, fixture.name, READ_SZ, encryption ? ENC_SIZE_CLOSE_ENOUGH_PERCENT : null)
|
|
310
323
|
})
|