Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/blockstore-s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export class S3Blockstore extends BaseBlockstore {
return new Uint8Array(buf, 0, buf.byteLength)
}

// @ts-expect-error s3 types define their own Blob as an empty interface
return await toBuffer(data.Body)
} catch (err: any) {
if (err.statusCode === 404) {
Expand Down
3 changes: 3 additions & 0 deletions packages/datastore-core/test/mount.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ describe('MountDatastore', () => {
}, {
prefix: new Key('/q'),
datastore: new MemoryDatastore()
}, {
prefix: new Key('/dht/provider/third'),
datastore: new MemoryDatastore()
}])
},
teardown () { }
Expand Down
4 changes: 2 additions & 2 deletions packages/datastore-fs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class FsDatastore extends BaseDatastore {
// strip leading slashes
prefix = prefix.replace(/^\/+/, '')

const pattern = `${prefix}/*${this.extension}`
const pattern = `${prefix}/**/*${this.extension}`
.split(path.sep)
.join('/')
const files = glob(this.path, pattern, {
Expand Down Expand Up @@ -278,7 +278,7 @@ export class FsDatastore extends BaseDatastore {
// strip leading slashes
prefix = prefix.replace(/^\/+/, '')

const pattern = `${prefix}/*${this.extension}`
const pattern = `${prefix}/**/*${this.extension}`
.split(path.sep)
.join('/')
const files = glob(this.path, pattern, {
Expand Down
1 change: 0 additions & 1 deletion packages/datastore-s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ export class S3Datastore extends BaseDatastore {
return new Uint8Array(buf, 0, buf.byteLength)
}

// @ts-expect-error s3 types define their own Blob as an empty interface
return await toBuffer(data.Body)
} catch (err: any) {
if (err.statusCode === 404) {
Expand Down
16 changes: 10 additions & 6 deletions packages/interface-datastore-tests/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ export function interfaceDatastoreTests <D extends Datastore = Datastore> (test:
const hello = { key: new Key('/q/1hello'), value: uint8ArrayFromString('1') }
const world = { key: new Key('/z/2world'), value: uint8ArrayFromString('2') }
const hello2 = { key: new Key('/z/3hello2'), value: uint8ArrayFromString('3') }
const many = { key: new Key('/dht/provider/third/bafyyyyy'), value: uint8ArrayFromString('4') }

const filter1: QueryFilter = entry => !entry.key.toString().endsWith('hello')
const filter2: QueryFilter = entry => entry.key.toString().endsWith('hello2')
Expand All @@ -432,14 +433,15 @@ export function interfaceDatastoreTests <D extends Datastore = Datastore> (test:
}

const tests: Array<[string, any, any[] | number]> = [
['empty', {}, [hello, world, hello2]],
['empty', {}, [hello, world, hello2, many]],
['prefix', { prefix: '/z' }, [world, hello2]],
['1 filter', { filters: [filter1] }, [world, hello2]],
['prefix-three-slashes', { prefix: '/dht/provider' }, [many]],
['1 filter', { filters: [filter1] }, [world, hello2, many]],
['2 filters', { filters: [filter1, filter2] }, [hello2]],
['limit', { limit: 1 }, 1],
['offset', { offset: 1 }, 2],
['1 order (1)', { orders: [order1] }, [hello, world, hello2]],
['1 order (reverse 1)', { orders: [order2] }, [hello2, world, hello]]
['offset', { offset: 1 }, 3],
['1 order (1)', { orders: [order1] }, [hello, world, hello2, many]],
['1 order (reverse 1)', { orders: [order2] }, [many, hello2, world, hello]]
]

before(async () => {
Expand All @@ -450,6 +452,7 @@ export function interfaceDatastoreTests <D extends Datastore = Datastore> (test:
b.put(hello.key, hello.value)
b.put(world.key, world.value)
b.put(hello2.key, hello2.value)
b.put(many.key, many.value)

await b.commit()
})
Expand Down Expand Up @@ -511,7 +514,8 @@ export function interfaceDatastoreTests <D extends Datastore = Datastore> (test:
expect(results.map(result => result.key)).to.have.deep.members([
hello.key,
world.key,
hello3.key
hello3.key,
many.key
])
})

Expand Down
Loading