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

add an option to deep-copy symlinks #15

Closed
yasushi-saito opened this issue Mar 3, 2020 · 5 comments
Closed

add an option to deep-copy symlinks #15

yasushi-saito opened this issue Mar 3, 2020 · 5 comments

Comments

@yasushi-saito
Copy link
Contributor

yasushi-saito commented Mar 3, 2020

Can we have an option to copy symlinks? I'm imagining something like:

Opts struct {
  // Called if a symlink is found. If this function returns false, 
  // Copy copies the symlink itself. Else, Copy() follows the link.
  // If FollowSymlink=nil, Copy never follows symlinks.
  FollowSymlink func(path string) bool
}

func Copy(src, dest string, opt... Opts) error;

I can create a pull request if it looks good.

@otiai10
Copy link
Owner

otiai10 commented Mar 3, 2020

Can you please list up expected usecases of this option first?

@otiai10
Copy link
Owner

otiai10 commented Mar 3, 2020

From my perspective, there are 3 usecases when it comes to symlink:

  1. Hard copy
  2. Soft copy (create a link to the same resource)
  3. Ignore

What do you think?

@yasushi-saito
Copy link
Contributor Author

Yes, the only feature I need now is deep-copies (i.e., follow all symlinks). So we can just have

type Opt struct { FollowSymlink bool }

I can't think a use case to ignore symlinks.

@otiai10
Copy link
Owner

otiai10 commented Mar 4, 2020

OK, then

  1. Hard copy ← is this what you want?
  2. Soft copy (create symlink) (follow) what you want
  3. Others (Skip?)

Is it right?

@otiai10
Copy link
Owner

otiai10 commented Mar 4, 2020

hmm, confusing... I'm still not sure what you want since your test cases are not descriptive enough and even failing.

This was referenced Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants