mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
reduce possibility of nil entry
This commit is contained in:
parent
be9c7c21ec
commit
bcf32591b7
|
@ -106,7 +106,7 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *f
|
||||||
|
|
||||||
glog.V(4).Infof("%v file setattr %+v", file.fullpath(), req)
|
glog.V(4).Infof("%v file setattr %+v", file.fullpath(), req)
|
||||||
|
|
||||||
_, err := file.maybeLoadEntry(ctx)
|
entry, err := file.maybeLoadEntry(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -123,12 +123,12 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *f
|
||||||
|
|
||||||
if req.Valid.Size() {
|
if req.Valid.Size() {
|
||||||
|
|
||||||
glog.V(4).Infof("%v file setattr set size=%v chunks=%d", file.fullpath(), req.Size, len(file.entry.Chunks))
|
glog.V(4).Infof("%v file setattr set size=%v chunks=%d", file.fullpath(), req.Size, len(entry.Chunks))
|
||||||
if req.Size < filer.FileSize(file.entry) {
|
if req.Size < filer.FileSize(entry) {
|
||||||
// fmt.Printf("truncate %v \n", fullPath)
|
// fmt.Printf("truncate %v \n", fullPath)
|
||||||
var chunks []*filer_pb.FileChunk
|
var chunks []*filer_pb.FileChunk
|
||||||
var truncatedChunks []*filer_pb.FileChunk
|
var truncatedChunks []*filer_pb.FileChunk
|
||||||
for _, chunk := range file.entry.Chunks {
|
for _, chunk := range entry.Chunks {
|
||||||
int64Size := int64(chunk.Size)
|
int64Size := int64(chunk.Size)
|
||||||
if chunk.Offset+int64Size > int64(req.Size) {
|
if chunk.Offset+int64Size > int64(req.Size) {
|
||||||
// this chunk is truncated
|
// this chunk is truncated
|
||||||
|
@ -143,36 +143,36 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.entry.Chunks = chunks
|
entry.Chunks = chunks
|
||||||
file.entryViewCache, _ = filer.NonOverlappingVisibleIntervals(file.wfs.LookupFn(), chunks)
|
file.entryViewCache, _ = filer.NonOverlappingVisibleIntervals(file.wfs.LookupFn(), chunks)
|
||||||
file.reader = nil
|
file.reader = nil
|
||||||
}
|
}
|
||||||
file.entry.Attributes.FileSize = req.Size
|
entry.Attributes.FileSize = req.Size
|
||||||
file.dirtyMetadata = true
|
file.dirtyMetadata = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Valid.Mode() {
|
if req.Valid.Mode() {
|
||||||
file.entry.Attributes.FileMode = uint32(req.Mode)
|
entry.Attributes.FileMode = uint32(req.Mode)
|
||||||
file.dirtyMetadata = true
|
file.dirtyMetadata = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Valid.Uid() {
|
if req.Valid.Uid() {
|
||||||
file.entry.Attributes.Uid = req.Uid
|
entry.Attributes.Uid = req.Uid
|
||||||
file.dirtyMetadata = true
|
file.dirtyMetadata = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Valid.Gid() {
|
if req.Valid.Gid() {
|
||||||
file.entry.Attributes.Gid = req.Gid
|
entry.Attributes.Gid = req.Gid
|
||||||
file.dirtyMetadata = true
|
file.dirtyMetadata = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Valid.Crtime() {
|
if req.Valid.Crtime() {
|
||||||
file.entry.Attributes.Crtime = req.Crtime.Unix()
|
entry.Attributes.Crtime = req.Crtime.Unix()
|
||||||
file.dirtyMetadata = true
|
file.dirtyMetadata = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Valid.Mtime() {
|
if req.Valid.Mtime() {
|
||||||
file.entry.Attributes.Mtime = req.Mtime.Unix()
|
entry.Attributes.Mtime = req.Mtime.Unix()
|
||||||
file.dirtyMetadata = true
|
file.dirtyMetadata = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *f
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return file.saveEntry(file.entry)
|
return file.saveEntry(entry)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue