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

MFS Directory vs UnixFS/IO Directory #5084

Closed
schomatis opened this issue Jun 6, 2018 · 2 comments
Closed

MFS Directory vs UnixFS/IO Directory #5084

schomatis opened this issue Jun 6, 2018 · 2 comments
Assignees
Labels
topic/docs-ipfs Topic docs-ipfs topic/files Topic files topic/MFS Topic MFS

Comments

@schomatis
Copy link
Contributor

The mfs and the unixfs.io packages have both a Directory structure (the first containing the second) and both implementing an AddChild function (used in combination to add files/dirs to the MFS filesystem) which makes the code hard to understand when reading the MFS work flow (see #5081). It would seem that the rationale behind this is to have MFS representing an abstract directory and UnixFS providing the actual node to support that (but that is just my speculation).

The MFS Directory names its inner UnixFS/IO Directory as dirbuilder (without any comment) which makes it hard to understand their relationship besides what was previously mentioned,

https://github.com/ipfs/go-ipfs/blob/7853e53860805e08a212d78c4baa5d59bff99ba8/mfs/dir.go#L26-L41

https://github.com/ipfs/go-ipfs/blob/7853e53860805e08a212d78c4baa5d59bff99ba8/unixfs/io/dirbuilder.go#L28-L36

My main question right now is: what is the purpose of unixfs.io.Directory? If I understand correctly unixfs.FSNode is the UnixFS representaion for the directory, mfs.Directory is the same at the MFS layer, why is part of the UnixFS functionality regarding directories in a different structure (in unixfs.io.Directory)?

@schomatis schomatis added topic/docs-ipfs Topic docs-ipfs topic/files Topic files labels Jun 6, 2018
@schomatis schomatis added this to the Files API Documentation milestone Jun 6, 2018
@schomatis schomatis self-assigned this Jun 6, 2018
@schomatis schomatis changed the title MFS Directory vs UnixFS Directory MFS Directory vs UnixFS/IO Directory Jun 6, 2018
@Stebalien
Copy link
Member

unixfs.io.Directory exists for creating/reading/editing directories. However, it doesn't care about directory trees, propagating updates to parent directories, receiving updates from children, etc. It just allows one to perform explicit edits on a single directory.

mfs.Directory, on the other hand:

  • Handles concurrent updates (hopefully...).
  • Updates the directory when a child changes.
  • Signals the parent when it changes.
  • Caches children for better performance with rapid lookups/edits.

@schomatis
Copy link
Contributor Author

I see, my main question is why do we need another structure to encapsulate that functionality, why isn't it absorbed by either the UnixFS or the MFS layers. Let me dig deeper into the code and get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/docs-ipfs Topic docs-ipfs topic/files Topic files topic/MFS Topic MFS
Projects
None yet
Development

No branches or pull requests

2 participants