diff --git a/index.js b/index.js index 3b96470..d181e27 100644 --- a/index.js +++ b/index.js @@ -430,7 +430,7 @@ module.exports = class Hyperdrive extends ReadyResource { dls.push(blobs.core.download({ start: b.blockOffset, length: b.blockLength })) } - return new Download(this, undefined, { downloads: dls }) + return new Download(this, null, { downloads: dls }) } async downloadRange(dbRanges, blobRanges) { @@ -448,7 +448,7 @@ module.exports = class Hyperdrive extends ReadyResource { dls.push(blobs.core.download(range)) } - return new Download(this, undefined, { downloads: dls }) + return new Download(this, null, { downloads: dls }) } entries(range, opts) { @@ -482,7 +482,7 @@ module.exports = class Hyperdrive extends ReadyResource { // atm always recursive, but we should add some depth thing to it list(folder, opts = {}) { - if (typeof folder === 'object') return this.list(undefined, folder) + if (typeof folder === 'object' && folder !== null) return this.list(undefined, folder) folder = std(folder || '/', true) diff --git a/lib/download.js b/lib/download.js index 9202601..6febf28 100644 --- a/lib/download.js +++ b/lib/download.js @@ -37,12 +37,14 @@ module.exports = class Download extends ReadyResource { // ignore } - for await (const entry of drive.list(this.folder, this.options)) { - const b = entry.value.blob - if (!b) continue + if (this.folder !== null) { + for await (const entry of drive.list(this.folder, this.options)) { + const b = entry.value.blob + if (!b) continue - const blobs = await drive.getBlobs() - this.downloads.push(blobs.core.download({ start: b.blockOffset, length: b.blockLength })) + const blobs = await drive.getBlobs() + this.downloads.push(blobs.core.download({ start: b.blockOffset, length: b.blockLength })) + } } } diff --git a/test.js b/test.js index 6ddaeea..083945d 100644 --- a/test.js +++ b/test.js @@ -806,7 +806,7 @@ test('drive.downloadDiff(version, folder, [options])', async (t) => { await mirror.drive.get('/parent/child/1') t.is(filescount, filestelem.count) - t.is(blobscount, blobstelem.count) + t.is(blobscount + 1, blobstelem.count) await drive.put('/parent/child/2', nil)