Merge pull request #702 from harshavardhana/pr_out_ignore_non_regular_files_after_following_the_file

This commit is contained in:
Harshavardhana
2015-05-27 13:44:56 -07:00
+35 -28
View File
@@ -178,7 +178,6 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) {
}
return
}
switch fi.Mode().IsDir() {
case true:
// do not use ioutil.ReadDir(), since it tries to sort its
@@ -207,20 +206,22 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) {
return
}
}
content := &client.Content{
Name: fi.Name(),
Time: fi.ModTime(),
Size: fi.Size(),
Type: fi.Mode(),
}
contentCh <- client.ContentOnChannel{
Content: content,
Err: nil,
if fi.Mode().IsRegular() || fi.Mode().IsDir() {
content := &client.Content{
Name: fi.Name(),
Time: fi.ModTime(),
Size: fi.Size(),
Type: fi.Mode(),
}
contentCh <- client.ContentOnChannel{
Content: content,
Err: nil,
}
}
}
default:
content := &client.Content{
Name: f.path,
Name: fi.Name(),
Time: fi.ModTime(),
Size: fi.Size(),
Type: fi.Mode(),
@@ -239,29 +240,35 @@ func (f *fsClient) listRecursiveInRoutine(contentCh chan client.ContentOnChannel
if fp == f.path {
return nil
}
if err != nil {
if strings.Contains(err.Error(), "operation not permitted") ||
// os.IsNotExist(err) ||
os.IsPermission(err) { // skip inaccessible files
return nil
}
return iodine.New(err, nil) // abort
}
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
fi, err = os.Stat(fp)
if err != nil {
if os.IsNotExist(err) { // ignore broken symlinks
return nil
}
return iodine.New(err, nil)
}
}
content := &client.Content{
Name: fp,
Time: fi.ModTime(),
Size: fi.Size(),
Type: fi.Mode(),
}
contentCh <- client.ContentOnChannel{
Content: content,
Err: nil,
if fi.Mode().IsRegular() || fi.Mode().IsDir() {
if err != nil {
if strings.Contains(err.Error(), "operation not permitted") {
return nil
}
if os.IsPermission(err) {
return nil
}
return iodine.New(err, nil) // abort
}
content := &client.Content{
Name: fp,
Time: fi.ModTime(),
Size: fi.Size(),
Type: fi.Mode(),
}
contentCh <- client.ContentOnChannel{
Content: content,
Err: nil,
}
}
return nil
}