diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-07-05 23:16:34 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-07-05 23:16:34 -0700 |
| commit | c8234a5af6cacde4b7bfab2de5339bca4aecfd1c (patch) | |
| tree | 6b01f2b9b6a876f21dc69fa43bce7276ec027235 /weed/filesys/filehandle.go | |
| parent | 77fc8c59140537bb693ccf44c63e68626322b70e (diff) | |
| download | seaweedfs-c8234a5af6cacde4b7bfab2de5339bca4aecfd1c.tar.xz seaweedfs-c8234a5af6cacde4b7bfab2de5339bca4aecfd1c.zip | |
ensure using none nil attributes
fix https://github.com/chrislusf/seaweedfs/issues/674
Diffstat (limited to 'weed/filesys/filehandle.go')
| -rw-r--r-- | weed/filesys/filehandle.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 74125dc09..03eed0a6f 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -18,6 +18,7 @@ type FileHandle struct { // cache file has been written to dirtyPages *ContinuousDirtyPages dirtyMetadata bool + contentType string handle uint64 @@ -145,7 +146,7 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f resp.Size = len(req.Data) if req.Offset == 0 { - fh.f.attributes.Mime = http.DetectContentType(req.Data) + fh.contentType = http.DetectContentType(req.Data) fh.dirtyMetadata = true } @@ -197,6 +198,10 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error { err = fh.f.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error { + if fh.f.attributes != nil { + fh.f.attributes.Mime = fh.contentType + } + request := &filer_pb.UpdateEntryRequest{ Directory: fh.f.dir.Path, Entry: &filer_pb.Entry{ |
