mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
ensure using none nil attributes
fix https://github.com/chrislusf/seaweedfs/issues/674
This commit is contained in:
parent
77fc8c5914
commit
c8234a5af6
|
@ -18,6 +18,7 @@ type FileHandle struct {
|
||||||
// cache file has been written to
|
// cache file has been written to
|
||||||
dirtyPages *ContinuousDirtyPages
|
dirtyPages *ContinuousDirtyPages
|
||||||
dirtyMetadata bool
|
dirtyMetadata bool
|
||||||
|
contentType string
|
||||||
|
|
||||||
handle uint64
|
handle uint64
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f
|
||||||
resp.Size = len(req.Data)
|
resp.Size = len(req.Data)
|
||||||
|
|
||||||
if req.Offset == 0 {
|
if req.Offset == 0 {
|
||||||
fh.f.attributes.Mime = http.DetectContentType(req.Data)
|
fh.contentType = http.DetectContentType(req.Data)
|
||||||
fh.dirtyMetadata = true
|
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 {
|
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{
|
request := &filer_pb.UpdateEntryRequest{
|
||||||
Directory: fh.f.dir.Path,
|
Directory: fh.f.dir.Path,
|
||||||
Entry: &filer_pb.Entry{
|
Entry: &filer_pb.Entry{
|
||||||
|
|
Loading…
Reference in a new issue