Survive indexing dead symlinks (#2645)

* survive indexing branches that start with a bad symlink

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* add log statement

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2024-02-14 21:06:22 +00:00
committed by GitHub
parent a909e3cec9
commit 65cadda486
3 changed files with 20 additions and 0 deletions
@@ -176,6 +176,13 @@ func isRealPath(root string) (bool, error) {
func (r *directoryIndexer) indexBranch(root string, stager *progress.Stage) ([]string, error) {
rootRealPath, err := filepath.EvalSymlinks(root)
if err != nil {
var pathErr *os.PathError
if errors.As(err, &pathErr) {
// we can't index the path, but we shouldn't consider this to be fatal
// TODO: known-unknowns
log.WithFields("root", root, "error", err).Trace("unable to evaluate symlink while indexing branch")
return nil, nil
}
return nil, err
}