mobiletto 1.0.37 → 1.0.40
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 +6 -5
- package/package.json +1 -1
- package/test/index.spec.js +18 -1
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,23 @@ 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, with or without a trailing slash", async () => {
|
|
314
|
+
const noSlash = await fixture.api.list(randomParent)
|
|
315
|
+
expect(noSlash).to.have.lengthOf.greaterThanOrEqual(1)
|
|
316
|
+
const withSlash = await fixture.api.list(randomParent+'/')
|
|
317
|
+
expect(withSlash).to.have.lengthOf.greaterThanOrEqual(1)
|
|
318
|
+
for (const f of noSlash) {
|
|
319
|
+
expect(withSlash.find(o => o.name === f.name)).to.not.be.null
|
|
320
|
+
}
|
|
321
|
+
for (const f of withSlash) {
|
|
322
|
+
expect(noSlash.find(o => o.name === f.name)).to.not.be.null
|
|
323
|
+
}
|
|
324
|
+
})
|
|
308
325
|
it("should load metadata for one of the new files", async () => {
|
|
309
326
|
await assertMeta(fixture.api, fixture.name, READ_SZ, encryption ? ENC_SIZE_CLOSE_ENOUGH_PERCENT : null)
|
|
310
327
|
})
|