From 4e7eeb0725abcd36b54a37636ff89f29c3238fd8 Mon Sep 17 00:00:00 2001 From: Praveen raj Mani Date: Sat, 22 Dec 2018 03:08:12 +0530 Subject: [PATCH] Ignore broken symlink durring mirror (#2607) Fixes #2604 --- cmd/client-fs.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/client-fs.go b/cmd/client-fs.go index 2ebb9a46..e8479aed 100644 --- a/cmd/client-fs.go +++ b/cmd/client-fs.go @@ -624,7 +624,8 @@ func (f *fsClient) listInRoutine(contentCh chan<- *clientContent) { for _, file := range files { fi := file if fi.Mode()&os.ModeSymlink == os.ModeSymlink { - fi, e = os.Stat(filepath.Join(fpath, fi.Name())) + fp := filepath.Join(fpath, fi.Name()) + fi, e = os.Stat(fp) if os.IsPermission(e) { contentCh <- &clientContent{ Err: probe.NewError(PathInsufficientPermission{Path: pathURL.Path}), @@ -632,8 +633,12 @@ func (f *fsClient) listInRoutine(contentCh chan<- *clientContent) { continue } if os.IsNotExist(e) { + // Lstat makes no attempt to follow the broken link. + _, e = os.Lstat(fp) contentCh <- &clientContent{ - Err: probe.NewError(BrokenSymlink{Path: file.Name()}), + URL: pathURL, + Size: -1, + Err: probe.NewError(e), } continue } @@ -810,10 +815,13 @@ func (f *fsClient) listRecursiveInRoutine(contentCh chan *clientContent) { } return nil } - // Ignore in-accessible broken symlinks. if os.IsNotExist(e) { + // Lstat makes no attempt to follow the broken link. + _, e = os.Lstat(fp) contentCh <- &clientContent{ - Err: probe.NewError(BrokenSymlink{Path: fp}), + URL: *newClientURL(fp), + Size: -1, + Err: probe.NewError(e), } return nil }