diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-04-17 10:48:22 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-04-18 13:07:28 -0700 |
| commit | 6cbd786db9b96833248444c42992c239f2424d95 (patch) | |
| tree | d9ff8c06b5664858d14e16cfdf04b7eca95aabe0 /weed/filesys/dir.go | |
| parent | d41e6826d3a0a51750e3f9c14b33a6aa9953bb09 (diff) | |
| download | seaweedfs-6cbd786db9b96833248444c42992c239f2424d95.tar.xz seaweedfs-6cbd786db9b96833248444c42992c239f2424d95.zip | |
correctly runs git clone
Diffstat (limited to 'weed/filesys/dir.go')
| -rw-r--r-- | weed/filesys/dir.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.go index b3577dcf0..3588a5951 100644 --- a/weed/filesys/dir.go +++ b/weed/filesys/dir.go @@ -24,6 +24,7 @@ type Dir struct { wfs *WFS entry *filer_pb.Entry parent *Dir + id uint64 } var _ = fs.Node(&Dir{}) @@ -44,7 +45,7 @@ var _ = fs.NodeListxattrer(&Dir{}) var _ = fs.NodeForgetter(&Dir{}) func (dir *Dir) Id() uint64 { - return util.FullPath(dir.FullPath()).AsInode() + return dir.id } func (dir *Dir) Attr(ctx context.Context, attr *fuse.Attr) error { @@ -64,7 +65,7 @@ func (dir *Dir) Attr(ctx context.Context, attr *fuse.Attr) error { return err } - attr.Inode = util.FullPath(dir.FullPath()).AsInode() + attr.Inode = dir.Id() attr.Mode = os.FileMode(entry.Attributes.FileMode) | os.ModeDir attr.Mtime = time.Unix(entry.Attributes.Mtime, 0) attr.Crtime = time.Unix(entry.Attributes.Crtime, 0) @@ -110,16 +111,28 @@ func (dir *Dir) Fsync(ctx context.Context, req *fuse.FsyncRequest) error { } func (dir *Dir) newFile(name string) fs.Node { + + fileFullPath := util.NewFullPath(dir.FullPath(), name) + fileId := fileFullPath.AsInode() + dir.wfs.handlesLock.Lock() + existingHandle, found := dir.wfs.handles[fileId] + dir.wfs.handlesLock.Unlock() + + if found { + glog.V(4).Infof("newFile found opened file handle: %+v", fileFullPath) + return existingHandle.f + } return &File{ - Name: name, - dir: dir, - wfs: dir.wfs, + Name: name, + dir: dir, + wfs: dir.wfs, + id: fileId, } } func (dir *Dir) newDirectory(fullpath util.FullPath) fs.Node { - return &Dir{name: fullpath.Name(), wfs: dir.wfs, parent: dir} + return &Dir{name: fullpath.Name(), wfs: dir.wfs, parent: dir, id: fullpath.AsInode()} } |
