Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileTree "Null"s are either not created properly or not parsed whatsoever (and breaks the folder) #18

Open
ahm23 opened this issue Sep 1, 2024 · 0 comments

Comments

@ahm23
Copy link

ahm23 commented Sep 1, 2024

Hello friends,
I've stumbled onto something while tinkering and testing.

I've found that the FileTree (FT) Null is getting created at the full path of the deleted target + a ref index, not at the parent folder of the delete target. This doesn't work since the parent of the Null is getting deleted, and so deleteTargets does not work (well, I'm pretty sure that's why its not working). The chain responds with a "Parent folder does not exist" and the associated hex is most definitely not the parent folder(?).

const pkg: IFileTreePackage = {
meta: await NullMetaHandler.create(target),
aes: await genAesBundle()
}
msgs.push(...(await this.filetreeDeleteToMsgs(pkg)))

protected async encodeFileTreeNull(
pkg: IFileTreePackage,
): Promise<DEncodeObject> {
try {
const mH = pkg.meta as INullMetaHandler
const meta = mH.export()
const parentAndChild = await merkleParentAndIndex(
mH.getLocation(),
mH.getRefString(),
)
return await this.storageEncodeFileTree(parentAndChild, meta, { aes: pkg.aes })
} catch (err) {
throw warnError('encodingHandler encodeFileTreeNull()', err)
}
}

Even if you change the path argument for the NullMetaHandler initializer to the path of the actual parent folder (as seen below), this does not fix the problem because you're replacing the Ref in the parent folder with a Null at the deleted file's Ref index.

await NullMetaHandler.create((ft as IBaseMetaData).location)

If this is the intended behaviour, then some code needs to be changed in FiletreeReader.pathToLookupPostProcess( ). Currently that method assumes all items in a folder are references and nothing else; consequently things bug out and jackal.js assumes an empty/broken folder as if everything got wiped.

const refMeta = await this.loadRefMeta(
this.redpages[ownerAddress][path],
i,
)
const meta = await this.loadMetaByUlid(refMeta.pointsTo)

Notice how pathToLookupPostProcess treats Nulls as if they are at the same level as folders and files; hence why I am really confused as to what is the nature of a Null.

} else if (meta.metaDataType === 'file') {
const loopPath = `${path}/${meta.fileMeta.name}`
this.redpages[ownerAddress][loopPath] = refMeta.pointsTo
await this.setYellowpages(
loopPath,
ownerAddress,
refMeta.pointsTo,
)
this.bluepages[ownerAddress][path].files[i] = meta
} else if (meta.metaDataType === 'null') {
const handler = await NullMetaHandler.create(meta.location, i)
this.bluepages[ownerAddress][path].nulls[i] = handler
}

If not, we'd need to change the location of the Null to the location of the deleted file (s/ulid/<deleted file ulid>) and eliminate any sort of refIndex from the equation.

There seems to be something similar going on with the metadata initialization of shared folders but it doesn't seem to be something broken or detremental to jackal.js functionality if I'm not mistaken.

Anyhow, I'm not sure what the envisioned way to use FT Nulls is and they are treated differently in different parts of the code so I can't do a PR for this. Let me know if you have any further questions.

@ahm23 ahm23 changed the title FileTree "Null"s are either not created properly or not parsed FileTree "Null"s are either not created properly or not parsed whatsoever (and breaks the folder) Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant