otiai10 / copy

Go copy directory recursively

Home Page:https://pkg.go.dev/github.com/otiai10/copy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Symlinks don't resolve relative paths properly

claassen opened this issue · comments

When copying a directory to another directory that is at a different path level, symlinks that resolve to relative paths fail to be copied as the source path of the symlink is not resolved to the absolute path.

Example:

Source folder:
src/
a/
someFile
b/
someFile (symlink to '../a/someFile')

Copy("src", "dest")

will work fine, however:

`Copy("src", "../dest") fails with:

readlink "dest/a/someFile": no such file or directory

What is happening as when using os.ReadLink, e.g.:

src, _ := os.Readlink("src/b/someFile")

src is return as "../a/someFile"

but it should really be expanded to the full path of "src/a/someFile", e.g. using filepath.Abs(src)

@claassen is this closed?

Hello @otiai10!

I'm also facing this issue, is there any workaround to have relative path resolved properly on symlinks?

Thank you!

Can we reopen this issue? Any progress on this? This is blocking https://github.com/GoogleCloudPlatform/hpc-toolkit from using symlinks.