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

implement symlinks in unixfs, first draft #1627

Merged
merged 7 commits into from
Sep 2, 2015
Merged

implement symlinks in unixfs, first draft #1627

merged 7 commits into from
Sep 2, 2015

Conversation

whyrusleeping
Copy link
Member

Implemented basic symlink support. Most commands dont follow them yet, need to figure out semantics for things like ipfs cat QmSymlink. But they are supported in the fuse mounts.

License: MIT
Signed-off-by: Jeromy jeromyj@gmail.com

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
@jbenet jbenet added the status/in-progress In progress label Aug 30, 2015
@@ -84,10 +84,25 @@ func (f *serialFile) NextFile() (File, error) {
// open the next file
fileName := fp.Join(f.name, stat.Name())
filePath := fp.Join(f.path, stat.Name())
st, err := os.Lstat(filePath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Must this (and ModeSymlink check, and if they are handled identically) happen before every os.Open() across the code?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that we only care to handle symlinks like that here, where the primary use case is ipfs add -r.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

In that case, it wouldnt make sense not to follow the symlink. What are you going to do with a single symlink inside ipfs? A symlink out of context is fairly useless, and potentially dangerous.

Copy link
Contributor

Choose a reason for hiding this comment

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

The option should not be a hard-coded "only create symlink if '-r'", but rather another flag to dereference the symlinks, regardless it is a single symlink or '-r' symlink.

If it is potentially dangerous to create a single symlink, then there should be a warning message instead, not hard-coded.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jbenet decision?

Copy link
Contributor

Choose a reason for hiding this comment

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

(regardless of the decision, the default is no dereference, so this PR can be landed without the flag)

Copy link
Member

Choose a reason for hiding this comment

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

If this PR is back to the default today (i.e. not breaking expectations) i'm good to land this.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jbenet alright, so 'ipfs add thisIsASymlink' should do what?

Copy link
Member

Choose a reason for hiding this comment

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

(from a discussion on irc, symlinks should be added by default. i.e. "in git we trust")

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
mfr.currentFile = s

// TODO(why): this is a hack. pick a real contentType
contentType = "symlink"
Copy link
Member

Choose a reason for hiding this comment

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

maybe application/symlink ? not sure. is there a symlink mime type?

Copy link
Member Author

Choose a reason for hiding this comment

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

i'd be fine with application/symlink. Googling around doesnt really give anything official for symlinks.

Copy link
Contributor

Choose a reason for hiding this comment

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

(decoupled from this PR) Should the 'ipfs add' api be simplified where files are always archived (and optionally gzipped)?
This is already what ipfs get does.

Will this simplify api writing (e.g. then multipart handling will become archive.Extract() in each lang)?

Copy link
Contributor

Choose a reason for hiding this comment

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

On Tue, Sep 01, 2015 at 06:11:01PM -0700, Jeromy Johnson wrote:

i'd be fine with application/symlink. Googling around doesnt
really give anything official for symlinks.

Sorry for the long silence, but wouldn't it be easier to just use our
regular file MIME type? Like I did in #1413 with a71c07a 1?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for symlink as a regular file with ModeSymlink.
Though I think it is possible to write a more lightweight version of that PR (and part of this PR) without the fileinfo.go

+1 vote for sending an archive to the api pipe (tar for now, later dag).
This will decouple the current api writing/porting into api rest parsing & porting the dag archive extractor library (tar for now).

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
@jbenet
Copy link
Member

jbenet commented Sep 2, 2015

@whyrusleeping ok LGTM. Looks like all commits pass. 👏 👏 👏 👏 👏 long time coming

jbenet added a commit that referenced this pull request Sep 2, 2015
implement symlinks in unixfs, first draft
@jbenet jbenet merged commit 006cd5f into master Sep 2, 2015
@jbenet jbenet removed the status/in-progress In progress label Sep 2, 2015
@jbenet jbenet deleted the feat/symlinks branch September 2, 2015 20:36
@rht
Copy link
Contributor

rht commented Sep 3, 2015

BuildDagFromFile and coreunix.AddR still doesn't make symlink by default.

@rht
Copy link
Contributor

rht commented Sep 3, 2015

Fixed in #1629

@rht
Copy link
Contributor

rht commented Sep 3, 2015

ipfs add -r go-multihash no longer chokes.

@whyrusleeping
Copy link
Member Author

@rht 😄

@whyrusleeping
Copy link
Member Author

BuildDagFromFile and coreunix.AddR still doesn't make symlink by default.

Ah, yeah. Should probably fix those too.

@rht
Copy link
Contributor

rht commented Sep 3, 2015

Can be closed: #979

@rht
Copy link
Contributor

rht commented Sep 3, 2015

Can be closed: #616

@rht
Copy link
Contributor

rht commented Sep 3, 2015

Can be closed: #1408 (there is still pipe bug #1409 (fixed in #1413), but #1408 test case is specifically on broken symlink, because the example is on go-multihash).

@rht
Copy link
Contributor

rht commented Sep 3, 2015

(looks like an issue's urgency is measured by the amount of duplicates it has)

@whyrusleeping
Copy link
Member Author

(looks like an issue's urgency is measured by the amount of duplicates it has)

@rht amen to that.

@jbenet jbenet mentioned this pull request Sep 3, 2015
12 tasks
@ajnavarro ajnavarro mentioned this pull request Aug 24, 2022
72 tasks
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.

5 participants