You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to manipulate a loaded mantaray node and I'm facing an issue removing paths when there are other siblings paths with the same prefix.
This is un example script:
run()asyncfunctionrun(){batchId=awaitcreatePostageBatch()constdata=Buffer.from("Test")constqueue=newQueue()constzeroHash=newUint8Array(64).fill(0)asReferenceconsthash=enqueueData(data,queue)conststorageSaver=async(data: Uint8Array)=>enqueueData(data,queue)conststorageLoader=async(reference: Uint8Array)=>awaitdownloadData(reference)constpath1=encodePath("path1")constpath2=encodePath("path2")constpath3=encodePath("path3")// 1. create a node with two forks with the same contentconstnode=newMantarayNode()node.addFork(encodePath(RootPath),zeroHash,{[WebsiteIndexDocumentSuffixKey]: decodePath(path1),})node.addFork(path1,hash,{[EntryMetadataContentTypeKey]: "text/plain",[EntryMetadataFilenameKey]: "test1",})node.addFork(path2,hash,{[EntryMetadataContentTypeKey]: "text/plain",[EntryMetadataFilenameKey]: "test2",})node.addFork(path3,hash,{[EntryMetadataContentTypeKey]: "text/plain",[EntryMetadataFilenameKey]: "test3",})node.removePath(path3)// <-- this works just fineconstmanifestReference=awaitnode.save(storageSaver)awaitqueue.drain()// test downloadconsttest1Resp=awaitfetch(`${Host}/bzz/${toHexString(manifestReference)}/${decodePath(path1)}`,{headers: {"Accept-Encoding": "identity",},})consttest2Resp=awaitfetch(`${Host}/bzz/${toHexString(manifestReference)}/${decodePath(path2)}`,{headers: {"Accept-Encoding": "identity",},})consttest1=awaittest1Resp.text()consttest2=awaittest2Resp.text()console.log(`1. Path 1: '${test1}'`)console.log(`1. Path 2: '${test2}'`)// 2. Load the node from swarm and remove one of the forks// load mantary nodeconstnode2=newMantarayNode()awaitnode2.load(storageLoader,manifestReference)node2.removePath(path2)// <-- this failsconstmanifestReference2=awaitnode.save(storageSaver)awaitqueue.drain()// test downloadconsttest3Resp=awaitfetch(`${Host}/bzz/${toHexString(manifestReference2)}/${decodePath(path1)}`,{headers: {"Accept-Encoding": "identity",},})consttest3=awaittest3Resp.text()console.log(`2. Path 1: '${test3}'`)}
The first removePath works but the second one, the one called after the node loading, throws the error Fork mapping is not defined in the manifest.
If I change path1, path2, path3 into something like a-path, c-path, c-path it works fine.
The text was updated successfully, but these errors were encountered:
publicasyncload(storageLoader: StorageLoader,reference: Reference): Promise<void>{if(!reference)throwError("Reference is undefined at manifest load")awaitthis.recursiveLoad(storageLoader,reference)this.setContentAddress=reference}
Can someone confirm that the loading is buggy and not intended to be that way? because in that case I could make a pull request.
I'm trying to manipulate a loaded mantaray node and I'm facing an issue removing paths when there are other siblings paths with the same prefix.
This is un example script:
The first
removePath
works but the second one, the one called after the node loading, throws the errorFork mapping is not defined in the manifest
.If I change
path1
,path2
,path3
into something likea-path
,c-path
,c-path
it works fine.The text was updated successfully, but these errors were encountered: