Ignore broken symlink durring mirror (#2607)

Fixes #2604
This commit is contained in:
Praveen raj Mani
2018-12-21 13:38:12 -08:00
committed by Harshavardhana
parent f0309e33e1
commit 4e7eeb0725
+12 -4
View File
@@ -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
}