Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Stat returns error when path is a symlink that point to a non-existent file #62

Closed
JinnyYi opened this issue Jul 27, 2021 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@JinnyYi
Copy link
Contributor

JinnyYi commented Jul 27, 2021

filepath.EvalSymlinks(path) will return lstat xxxxx: no such file or directory if path is a symlink and points to a non-existent file or directory.

Maybe we can use os.Readlink(name) instead as it can get the destination of the named symbolic link even if the target is not exist?

@JinnyYi JinnyYi added the bug Something isn't working label Jul 28, 2021
@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 28, 2021

LGTM, but Readlink only read once, we need to handle multiple links.

@JinnyYi
Copy link
Contributor Author

JinnyYi commented Jul 28, 2021

LGTM, but Readlink only read once, we need to handle multiple links.

How about use EvalSymlinks first? If we get the target not exist related error from EvalSymlinks, then we use Readlink to try to get the target.

@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 28, 2021

EvalSymlinks calls Readlink internally, this will add extra cost for it.

Maybe we can implement ourself EvalSymlinks: https://golang.org/src/path/filepath/symlink.go

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

@JinnyYi
Copy link
Contributor Author

JinnyYi commented Aug 5, 2021

Fixed in #64

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants