Open
Description
Repro:
import { importer } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core/memory'
import * as pb from '@ipld/dag-pb'
const blockstore = new MemoryBlockstore()
const source = [{
path: 'blob',
content: Buffer.from('first')
}, {
path: 'blob',
content: Buffer.from('seconds')
}]
const options = { cidVersion: 1, rawLeaves: true, wrapWithDirectory: true }
const entries = []
for await (const entry of importer(source, blockstore, options)) {
console.info(entry)
entries.push(entry)
}
const bytes = await blockstore.get(entries[entries.length - 1].cid)
console.log(pb.decode(bytes))
Output:
{
cid: CID(bafkreifhsn5wjogkuwhqg4q3w25m6xdyzmrv727a44frxbgntfkbiynary),
path: 'blob',
unixfs: undefined,
size: 5
}
{
cid: CID(bafkreicz6adnmo6qbg37d4oxxv7ctyptxhnwkboopbgkgilovegg23olce),
path: 'blob',
unixfs: undefined,
size: 7
}
{
cid: CID(bafybeicjuj5znbntswyl5qdqacqinysb37sdwky335oinjn3gt43bpvtki),
path: '',
unixfs: UnixFS {
type: 'directory',
data: undefined,
hashType: undefined,
fanout: undefined,
blockSizes: [],
_originalMode: 0,
_mode: 493
},
size: 59
}
{
Data: Uint8Array(2) [ 8, 1 ],
Links: [
{
Hash: CID(bafkreicz6adnmo6qbg37d4oxxv7ctyptxhnwkboopbgkgilovegg23olce),
Name: 'blob',
Tsize: 7
}
]
}
The directory node includes only the second "blob".
It should not silently succeed but should throw an error. Alternatively, create a directory with both.