|
|
@ -70,6 +70,8 @@ func (dir *Dir) Attr(context context.Context, attr *fuse.Attr) error { |
|
|
|
dir.attributes = resp.Entry.Attributes |
|
|
|
} |
|
|
|
|
|
|
|
dir.wfs.listDirectoryEntriesCache.Set(dir.Path, resp.Entry, 300*time.Millisecond) |
|
|
|
|
|
|
|
return nil |
|
|
|
}) |
|
|
|
|
|
|
@ -185,6 +187,13 @@ func (dir *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, err |
|
|
|
func (dir *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (node fs.Node, err error) { |
|
|
|
|
|
|
|
var entry *filer_pb.Entry |
|
|
|
|
|
|
|
item := dir.wfs.listDirectoryEntriesCache.Get(path.Join(dir.Path, req.Name)) |
|
|
|
if item != nil && !item.Expired() { |
|
|
|
entry = item.Value().(*filer_pb.Entry) |
|
|
|
} |
|
|
|
|
|
|
|
if entry == nil { |
|
|
|
err = dir.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error { |
|
|
|
|
|
|
|
request := &filer_pb.LookupDirectoryEntryRequest{ |
|
|
@ -201,8 +210,11 @@ func (dir *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse. |
|
|
|
|
|
|
|
entry = resp.Entry |
|
|
|
|
|
|
|
dir.wfs.listDirectoryEntriesCache.Set(path.Join(dir.Path, entry.Name), entry, 1000*time.Millisecond) |
|
|
|
|
|
|
|
return nil |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
if entry != nil { |
|
|
|
if entry.IsDirectory { |
|
|
@ -248,7 +260,7 @@ func (dir *Dir) ReadDirAll(ctx context.Context) (ret []fuse.Dirent, err error) { |
|
|
|
dirent := fuse.Dirent{Name: entry.Name, Type: fuse.DT_File} |
|
|
|
ret = append(ret, dirent) |
|
|
|
} |
|
|
|
dir.wfs.listDirectoryEntriesCache.Set(dir.Path+"/"+entry.Name, entry, 300*time.Millisecond) |
|
|
|
dir.wfs.listDirectoryEntriesCache.Set(path.Join(dir.Path, entry.Name), entry, 300*time.Millisecond) |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
@ -275,6 +287,8 @@ func (dir *Dir) Remove(ctx context.Context, req *fuse.RemoveRequest) error { |
|
|
|
return fuse.EIO |
|
|
|
} |
|
|
|
|
|
|
|
dir.wfs.listDirectoryEntriesCache.Delete(path.Join(dir.Path, req.Name)) |
|
|
|
|
|
|
|
return nil |
|
|
|
}) |
|
|
|
|
|
|
@ -317,6 +331,8 @@ func (dir *Dir) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fus |
|
|
|
return fuse.EIO |
|
|
|
} |
|
|
|
|
|
|
|
dir.wfs.listDirectoryEntriesCache.Delete(dir.Path) |
|
|
|
|
|
|
|
return nil |
|
|
|
}) |
|
|
|
|
|
|
|