Skip to content

Conversation

@drafnel
Copy link

@drafnel drafnel commented Jul 24, 2017

Commit 52f7192 taught NewResolver to detect when the basedir argument is
a symlink and to extract the target of the symlink and use it in place
of the original basedir. This works correctly and allows ResolveLocal
to walk the directory tree when the symlink target is a fully qualified
path to a directory. But, if the symlink points to another symlink, or
if it provides a relative path, then the traversal by filepath.Walk()
will fail as before.

The path/filepath package already provides a function to fully evaluate
a path and dereference any symbolic links: filepath.EvalSymlinks().

So instead of using checkForBasedirSymlink() to perform a single
dereference of basedir and storing that into the Resolver object, let's
just record the original path into the Resolver object and then call
filepath.EvalSymlinks() to fully resolve the path in ResolveLocal before
walking the tree with filepath.Walk().

Commit 52f7192 taught NewResolver to detect when the basedir argument is
a symlink and to extract the target of the symlink and use it in place
of the original basedir.  This works correctly and allows ResolveLocal
to walk the directory tree when the symlink target is a fully qualified
path to a directory.  But, if the symlink points to another symlink, or
if it provides a relative path, then the traversal by filepath.Walk()
will fail as before.

The path/filepath package already provides a function to fully evaluate
a path and dereference any symbolic links: filepath.EvalSymlinks().

So instead of using checkForBasedirSymlink() to perform a single
dereference of basedir and storing that into the Resolver object, let's
just record the original path into the Resolver object and then call
filepath.EvalSymlinks() to fully resolve the path in ResolveLocal before
walking the tree with filepath.Walk().
@drafnel
Copy link
Author

drafnel commented Aug 4, 2017

Ping. Hi @mattfarina can you take a look?

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.

1 participant