From b93d57da31fa09f724e38865258ada0fe414076a Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 24 Feb 2022 00:37:57 -0800 Subject: [PATCH] mount2: dir read opened file --- weed/mount/weedfs_dir_lookup.go | 5 +++++ weed/mount/weedfs_dir_read.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/weed/mount/weedfs_dir_lookup.go b/weed/mount/weedfs_dir_lookup.go index 4eceb5ce4..6d0e1d6fa 100644 --- a/weed/mount/weedfs_dir_lookup.go +++ b/weed/mount/weedfs_dir_lookup.go @@ -55,6 +55,11 @@ func (wfs *WFS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name strin inode := wfs.inodeToPath.Lookup(fullFilePath, localEntry.IsDirectory(), true) + if fh, found := wfs.fhmap.FindFileHandle(inode); found { + glog.V(4).Infof("lookup opened file %s size %d", dirPath.Child(localEntry.Name()), filer.FileSize(fh.entry)) + localEntry = filer.FromPbEntry(string(dirPath), fh.entry) + } + wfs.outputFilerEntry(out, inode, localEntry) return fuse.OK diff --git a/weed/mount/weedfs_dir_read.go b/weed/mount/weedfs_dir_read.go index 9e8587995..913d0ebeb 100644 --- a/weed/mount/weedfs_dir_read.go +++ b/weed/mount/weedfs_dir_read.go @@ -176,6 +176,10 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl isEarlyTerminated = true return false } + if fh, found := wfs.fhmap.FindFileHandle(inode); found { + glog.V(4).Infof("readdir opened file %s", dirPath.Child(dirEntry.Name)) + entry = filer.FromPbEntry(string(dirPath), fh.entry) + } wfs.outputFilerEntry(entryOut, inode, entry) } dh.lastEntryName = entry.Name()