Skip to content

fix(mfs): preserve CidBuilder object in setNodeData(), Mkdir() and NewRoot()#1125

Open
davidebeatrici wants to merge 3 commits intoipfs:mainfrom
davidebeatrici:mkdir-respect-cidbuilder
Open

fix(mfs): preserve CidBuilder object in setNodeData(), Mkdir() and NewRoot()#1125
davidebeatrici wants to merge 3 commits intoipfs:mainfrom
davidebeatrici:mkdir-respect-cidbuilder

Conversation

@davidebeatrici
Copy link
Copy Markdown

No description provided.

@davidebeatrici davidebeatrici requested a review from a team as a code owner March 23, 2026 18:02
Comment on lines -395 to -398
// hector: no idea why this option is overridden, but it must be to
// keep backwards compatibility. CidBuilder from the options is
// manually set in `Mkdir` (ops.go) though.
opts.CidBuilder = d.GetCidBuilder()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or rather:

if opts.CidBuilder == nil {
	opts.CidBuilder = d.GetCidBuilder()
}

Comment on lines 176 to 184
// opts to make the parents leave MkParents and Flush as false.
parentsOpts := MkdirOpts{
CidBuilder: opts.CidBuilder,
MaxLinks: opts.MaxLinks,
MaxHAMTFanout: opts.MaxHAMTFanout,
HAMTShardingSize: opts.HAMTShardingSize,
SizeEstimationMode: opts.SizeEstimationMode,
Chunker: opts.Chunker,
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment implies we can copy the entire struct object and then just set MkParents and Flush to false. Should we do that?

Comment on lines 372 to 377
return d.MkdirWithOpts(name, MkdirOpts{
CidBuilder: d.unixfsDir.GetCidBuilder(),
MaxLinks: d.unixfsDir.GetMaxLinks(),
MaxHAMTFanout: d.unixfsDir.GetMaxHAMTFanout(),
HAMTShardingSize: d.unixfsDir.GetHAMTShardingSize(),
})
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set SizeEstimationMode as well?

Copy link
Copy Markdown
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs in-depth review but dropping quick comment that this needs a PR in kubo that uses this branch to detect any regression in downstream projects

@davidebeatrici
Copy link
Copy Markdown
Author

Thank you, I'll do that as soon as I completely fix ipfs/kubo#11247.

I have to add a commit that fixes the file-specific issue to this pull request.

@davidebeatrici davidebeatrici force-pushed the mkdir-respect-cidbuilder branch from 614b36f to e79825c Compare March 24, 2026 21:27
@davidebeatrici davidebeatrici changed the title fix(mfs): use correct CidBuilder object in Mkdir() fix(mfs): preserve CidBuilder in Mkdir() and setNodeData() Mar 25, 2026
@davidebeatrici davidebeatrici force-pushed the mkdir-respect-cidbuilder branch from e79825c to 7df5f5b Compare March 27, 2026 00:02
@davidebeatrici davidebeatrici changed the title fix(mfs): preserve CidBuilder in Mkdir() and setNodeData() fix(mfs): preserve CidBuilder object in setNodeData(), Mkdir() and NewRoot() Mar 27, 2026
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

Successfully merging this pull request may close these issues.

2 participants