-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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: make Root
value a Directory
#5170
Merged
whyrusleeping
merged 3 commits into
ipfs:master
from
schomatis:feat/mfs/root-val-as-dir
Jul 16, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package mfs | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
gopath "path" | ||
|
@@ -129,7 +128,7 @@ func Mkdir(r *Root, pth string, opts MkdirOpts) error { | |
return fmt.Errorf("cannot create directory '/': Already exists") | ||
} | ||
|
||
cur := r.GetValue().(*Directory) | ||
cur := r.GetDirectory() | ||
for i, d := range parts[:len(parts)-1] { | ||
fsn, err := cur.Child(d) | ||
if err == os.ErrNotExist && opts.Mkparents { | ||
|
@@ -172,12 +171,11 @@ func Mkdir(r *Root, pth string, opts MkdirOpts) error { | |
return nil | ||
} | ||
|
||
// Lookup extracts the root directory and performs a lookup under it. | ||
// TODO: Now that the root is always a directory, can this function | ||
// be collapsed with `DirLookup`? Or at least be made a method of `Root`? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is used in many places within the code. I would be okay with making this a method of Root but would not collapse it with |
||
func Lookup(r *Root, path string) (FSNode, error) { | ||
dir, ok := r.GetValue().(*Directory) | ||
if !ok { | ||
log.Errorf("root not a dir: %#v", r.GetValue()) | ||
return nil, errors.New("root was not a directory") | ||
} | ||
dir := r.GetDirectory() | ||
|
||
return DirLookup(dir, path) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I need to get better about submitting comments instead of editing them till my browser crashes and they disappear...
This is the one real reason to allow the root to be something other than a directory. However, really, the "root" is just a way to tie a file/directory in an MFS tree to a publisher. I'd rather just:
Currently, we have the
childCloser
but I wonder if we want a more general system. Thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad I'm not the only one, I'm seriously considering submitting a feature request to GitHub that would allow me to explicitly save my drafts..
I was considering adding that logic to the directory implementation of
childCloser
, if the directory has a parent call the parent'scloseChild
(current behavior), if not (you are the root) call the republisher and tell it things have changed. That would require every directory to be aware of the republisher, either with a pointer to it or some other way (which is not nice). Anyway, I need to keep studying how the republisher works and see if I can come up with something better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of a more general purpose notification boadcast system where users could register and unregister any number of notifiees (where the parent directory would register itself as a notifiee).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate a bit more on that? I thought the directory was the notifier (I may be misunderstanding the word notifiee, that's the one that receives the notification, right?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated:
You can save a code comment with a "Start Review", comments will be visible only to you until you send the review.