mobiletto 1.0.37 → 1.0.38

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/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 dirent = direntDir(pth)
351
+ list: async (pth = '', recursive, visitor) => {
352
+ const p = pth === '' ? '.' : 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(pth));
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 === pth)
363
+ const found = objects.find(o => o.name === p)
363
364
  if (found) {
364
365
  return [ found ]
365
366
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobiletto",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "A storage abstraction layer",
5
5
  "main": "index.js",
6
6
  "author": "Jonathan Cobb",
@@ -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
- // const encryption = {key: rand(32)}
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,11 @@ 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
+ })
308
313
  it("should load metadata for one of the new files", async () => {
309
314
  await assertMeta(fixture.api, fixture.name, READ_SZ, encryption ? ENC_SIZE_CLOSE_ENOUGH_PERCENT : null)
310
315
  })