aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/file.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-01-19 23:59:46 -0800
committerChris Lu <chris.lu@gmail.com>2020-01-19 23:59:46 -0800
commit1b0bfbaf59ba613ebae6b90021b2270b3ac34bc5 (patch)
treee8b08130edd727e14b8e1608fdb7771aab0d5764 /weed/filesys/file.go
parent2f15e9346696d18032b9d2bfffe459635cb36171 (diff)
downloadseaweedfs-1b0bfbaf59ba613ebae6b90021b2270b3ac34bc5.tar.xz
seaweedfs-1b0bfbaf59ba613ebae6b90021b2270b3ac34bc5.zip
refactoring
Diffstat (limited to 'weed/filesys/file.go')
-rw-r--r--weed/filesys/file.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/weed/filesys/file.go b/weed/filesys/file.go
index ca0550a87..7e562eabc 100644
--- a/weed/filesys/file.go
+++ b/weed/filesys/file.go
@@ -3,14 +3,12 @@ package filesys
import (
"context"
"os"
- "path/filepath"
"sort"
"time"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
- "github.com/chrislusf/seaweedfs/weed/util"
"github.com/seaweedfs/fuse"
"github.com/seaweedfs/fuse/fs"
)
@@ -35,19 +33,22 @@ type File struct {
isOpen bool
}
-func (file *File) fullpath() string {
- return filepath.Join(file.dir.Path, file.Name)
+func (file *File) fullpath() filer2.FullPath {
+ return filer2.NewFullPath(file.dir.Path, file.Name)
}
func (file *File) Attr(ctx context.Context, attr *fuse.Attr) error {
glog.V(4).Infof("file Attr %s, open:%v, existing attr: %+v", file.fullpath(), file.isOpen, attr)
- if err := file.maybeLoadEntry(ctx); err != nil {
- return err
+ if !file.isOpen {
+ if err := file.maybeLoadEntry(ctx); err != nil {
+ return err
+ }
}
- attr.Inode = uint64(util.HashStringToLong(file.fullpath()))
+ attr.Inode = file.fullpath().AsInode()
+ attr.Valid = time.Second
attr.Mode = os.FileMode(file.entry.Attributes.FileMode)
attr.Size = filer2.TotalSize(file.entry.Chunks)
if file.isOpen {
@@ -132,7 +133,7 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *f
return nil
}
- file.wfs.listDirectoryEntriesCache.Delete(file.fullpath())
+ file.wfs.cacheDelete(file.fullpath())
return file.saveEntry(ctx)
@@ -150,7 +151,7 @@ func (file *File) Setxattr(ctx context.Context, req *fuse.SetxattrRequest) error
return err
}
- file.wfs.listDirectoryEntriesCache.Delete(file.fullpath())
+ file.wfs.cacheDelete(file.fullpath())
return file.saveEntry(ctx)
@@ -168,7 +169,7 @@ func (file *File) Removexattr(ctx context.Context, req *fuse.RemovexattrRequest)
return err
}
- file.wfs.listDirectoryEntriesCache.Delete(file.fullpath())
+ file.wfs.cacheDelete(file.fullpath())
return file.saveEntry(ctx)