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

Symbolic Links #616

Closed
mildred opened this issue Jan 22, 2015 · 6 comments
Closed

Symbolic Links #616

mildred opened this issue Jan 22, 2015 · 6 comments
Labels
topic/files Topic files

Comments

@mildred
Copy link
Contributor

mildred commented Jan 22, 2015

Symbolic links are not implemented. ipfs add -r on a directory containing a symlink to a directory will fail.

You can reproduce it using:

mkdir -p a/b
ln -s b a/c
touch a/b/c
ipfs add -r a

You get:

Error: Post http://127.0.0.1:5001/api/v0/add?encoding=json&r=true&stream-channels=true: read a/c: is a directory

I think I also got ipfs add -r to stop in the middle of adding because of that. At some point, it would just stop and not continue. Running stat, I found that it thought that the symlink to a directory was a file, and tried to read it:

open("root/ckeditor/plugins/openlink", O_RDONLY|O_CLOEXEC) = 5
read(5, 0xc208130000, 32768)            = -1 EISDIR (Is a directory)
epoll_wait(4, {}, 128, 0)               = 0
futex(0xf2e878, FUTEX_WAIT, 0, NULL)    = 0
futex(0xf2da30, FUTEX_WAKE, 1)          = 1
...

The normal sequence for a directory would be:

open("root/ckeditor/plugins/newpage/lang", O_RDONLY|O_CLOEXEC) = 5
getdents64(5, /* 68 entries */, 4096)   = 2160
getdents64(5, /* 0 entries */, 4096)    = 0
lstat("root/ckeditor/plugins/newpage/lang/fa.js", {st_mode=S_IFREG|0644, st_size=235, ...}) = 0
...

We should implement symbolic links in the unixfs protocol buffer object.

@mildred
Copy link
Contributor Author

mildred commented Jan 22, 2015

As far as ipfs add is concerned, we could do two things:

  • follow symlinks as if they were the target file (this is what we do currently apart from the bug above)
  • insert symlinks as such in the unixfs DAG

In any case, I think this should be configurable by a command line switch. Just like we have cp --no-dereference and cp --dereference

@jbenet
Copy link
Member

jbenet commented Jan 23, 2015

Error: Post http://127.0.0.1:5001/api/v0/add?encoding=json&r=true&stream-channels=true: read a/c: is a directory

@mappum we shouldn't show that url in the error o/

Agreed with your analysis @mildred, as discussed in #620 let's:

  • Default to inserting symlinks into unixfs (like git does)
  • Option to follow symlinks. whatever is most common in other unix utils.

@daviddias
Copy link
Member

@whyrusleeping Can we make getting symlinks working a priority?

@whyrusleeping
Copy link
Member

@diasdavid sure thing.

@whyrusleeping
Copy link
Member

Kachow!

@daviddias
Copy link
Member

💥 :D

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

No branches or pull requests

4 participants