Browse Source

do not read attributes when file is opened

pull/664/head
Chris Lu 7 years ago
parent
commit
ac66c133a5
  1. 1
      weed/filesys/dir.go
  2. 5
      weed/filesys/file.go
  3. 2
      weed/filesys/filehandle.go

1
weed/filesys/dir.go

@ -120,6 +120,7 @@ func (dir *Dir) Create(ctx context.Context, req *fuse.CreateRequest,
if err == nil { if err == nil {
file := dir.newFile(req.Name, nil) file := dir.newFile(req.Name, nil)
dir.NodeMap[req.Name] = file dir.NodeMap[req.Name] = file
file.isOpen = true
return file, &FileHandle{ return file, &FileHandle{
f: file, f: file,
RequestId: req.Header.ID, RequestId: req.Header.ID,

5
weed/filesys/file.go

@ -23,13 +23,14 @@ type File struct {
dir *Dir dir *Dir
wfs *WFS wfs *WFS
attributes *filer_pb.FuseAttributes attributes *filer_pb.FuseAttributes
isOpen bool
} }
func (file *File) Attr(context context.Context, attr *fuse.Attr) error { func (file *File) Attr(context context.Context, attr *fuse.Attr) error {
fullPath := filepath.Join(file.dir.Path, file.Name) fullPath := filepath.Join(file.dir.Path, file.Name)
if file.attributes == nil {
if file.attributes == nil || !file.isOpen {
item := file.wfs.listDirectoryEntriesCache.Get(fullPath) item := file.wfs.listDirectoryEntriesCache.Get(fullPath)
if item != nil { if item != nil {
entry := item.Value().(*filer_pb.Entry) entry := item.Value().(*filer_pb.Entry)
@ -80,6 +81,8 @@ func (file *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.Op
glog.V(3).Infof("%v file open %+v", fullPath, req) glog.V(3).Infof("%v file open %+v", fullPath, req)
file.isOpen = true
return &FileHandle{ return &FileHandle{
f: file, f: file,
RequestId: req.Header.ID, RequestId: req.Header.ID,

2
weed/filesys/filehandle.go

@ -184,6 +184,8 @@ func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) err
glog.V(3).Infof("%+v/%v release fh", fh.f.dir.Path, fh.f.Name) glog.V(3).Infof("%+v/%v release fh", fh.f.dir.Path, fh.f.Name)
fh.f.isOpen = false
return nil return nil
} }

Loading…
Cancel
Save