diff options
| author | chrislu <chris.lu@gmail.com> | 2022-02-16 21:32:15 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-02-16 21:32:15 -0800 |
| commit | 49b84b6e2a5565cc133c184e1a25a4110f76b24b (patch) | |
| tree | 4cc0ae2e8d9ba2775ef1f9aa008b935090921f8f /weed/mount/weedfs_dir_read.go | |
| parent | 65a19e3abc602ad829b427d3ec6813c7616aa7be (diff) | |
| download | seaweedfs-49b84b6e2a5565cc133c184e1a25a4110f76b24b.tar.xz seaweedfs-49b84b6e2a5565cc133c184e1a25a4110f76b24b.zip | |
list entries while reading from remote
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 } |
