diff options
Diffstat (limited to 'weed/mount/weedfs_dir_read.go')
| -rw-r--r-- | weed/mount/weedfs_dir_read.go | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/weed/mount/weedfs_dir_read.go b/weed/mount/weedfs_dir_read.go index 40726a694..a14f4d960 100644 --- a/weed/mount/weedfs_dir_read.go +++ b/weed/mount/weedfs_dir_read.go @@ -179,17 +179,33 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl return true } - if err := meta_cache.EnsureVisited(wfs.metaCache, wfs, dirPath); err != nil { - glog.Errorf("dir ReadDirAll %s: %v", dirPath, err) - return fuse.EIO + entryChan := make(chan *filer.Entry, 128) + var err error + go func() { + if err = meta_cache.EnsureVisited(wfs.metaCache, wfs, dirPath, entryChan); err != nil { + glog.Errorf("dir ReadDirAll %s: %v", dirPath, err) + } + close(entryChan) + }() + hasData := false + for entry := range entryChan { + hasData = true + processEachEntryFn(entry, false) } - listErr := wfs.metaCache.ListDirectoryEntries(context.Background(), dirPath, dh.lastEntryName, false, int64(math.MaxInt32), func(entry *filer.Entry) bool { - return processEachEntryFn(entry, false) - }) - if listErr != nil { - glog.Errorf("list meta cache: %v", listErr) + if err != nil { return fuse.EIO } + + if !hasData { + listErr := wfs.metaCache.ListDirectoryEntries(context.Background(), dirPath, dh.lastEntryName, false, int64(math.MaxInt32), func(entry *filer.Entry) bool { + return processEachEntryFn(entry, false) + }) + if listErr != nil { + glog.Errorf("list meta cache: %v", listErr) + return fuse.EIO + } + } + if !isEarlyTerminated { dh.isFinished = true } |
