aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/file.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-07-19 02:17:36 -0700
committerChris Lu <chris.lu@gmail.com>2018-07-19 02:17:36 -0700
commit13e5541e17a4c050eb4c9fe73ce52213e45dba83 (patch)
treea7afe415ede67a7fc56238c4b899170f1c6f875c /weed/filesys/file.go
parenta09ef6002a85df402caf7c8dc74dad7e196a3edf (diff)
downloadseaweedfs-13e5541e17a4c050eb4c9fe73ce52213e45dba83.tar.xz
seaweedfs-13e5541e17a4c050eb4c9fe73ce52213e45dba83.zip
FUSE can change file or folder attributes
FUSE can change file or folder attributes
Diffstat (limited to 'weed/filesys/file.go')
-rw-r--r--weed/filesys/file.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/weed/filesys/file.go b/weed/filesys/file.go
index 95f478a76..3f22f0571 100644
--- a/weed/filesys/file.go
+++ b/weed/filesys/file.go
@@ -34,7 +34,7 @@ func (file *File) Attr(ctx context.Context, attr *fuse.Attr) error {
if file.attributes == nil || !file.isOpen {
item := file.wfs.listDirectoryEntriesCache.Get(file.fullpath())
- if item != nil && !item.Expired(){
+ if item != nil && !item.Expired() {
entry := item.Value().(*filer_pb.Entry)
file.Chunks = entry.Chunks
file.attributes = entry.Attributes
@@ -121,7 +121,26 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *f
file.attributes.Mtime = req.Mtime.Unix()
}
- return nil
+ return file.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
+
+ request := &filer_pb.UpdateEntryRequest{
+ Directory: file.dir.Path,
+ Entry: &filer_pb.Entry{
+ Name: file.Name,
+ Attributes: file.attributes,
+ Chunks: file.Chunks,
+ },
+ }
+
+ glog.V(1).Infof("set attr file entry: %v", request)
+ _, err := client.UpdateEntry(ctx, request)
+ if err != nil {
+ glog.V(0).Infof("UpdateEntry file %s/%s: %v", file.dir.Path, file.Name, err)
+ return fuse.EIO
+ }
+
+ return nil
+ })
}