aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2023-01-10 01:07:34 -0800
committerchrislu <chris.lu@gmail.com>2023-01-10 01:07:34 -0800
commit28fe5789444b8c6d9dc7c8276599423c30af81b8 (patch)
treea2ae91acaa4310e90ae9946d054bc8ebca4eed93
parent47fa5ef979976efc6aa4b7e9d488d4e1244cd445 (diff)
downloadseaweedfs-28fe5789444b8c6d9dc7c8276599423c30af81b8.tar.xz
seaweedfs-28fe5789444b8c6d9dc7c8276599423c30af81b8.zip
avoid possible nil entry
-rw-r--r--weed/mount/weedfs_attr.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/weed/mount/weedfs_attr.go b/weed/mount/weedfs_attr.go
index 7dc3c6b50..9cd643d95 100644
--- a/weed/mount/weedfs_attr.go
+++ b/weed/mount/weedfs_attr.go
@@ -145,6 +145,11 @@ func (wfs *WFS) setRootAttr(out *fuse.AttrOut) {
func (wfs *WFS) setAttrByPbEntry(out *fuse.Attr, inode uint64, entry *filer_pb.Entry, calculateSize bool) {
out.Ino = inode
+ out.Blocks = (out.Size + blockSize - 1) / blockSize
+ setBlksize(out, blockSize)
+ if entry == nil {
+ return
+ }
if entry.Attributes != nil && entry.Attributes.Inode != 0 {
out.Ino = entry.Attributes.Inode
}
@@ -154,11 +159,6 @@ func (wfs *WFS) setAttrByPbEntry(out *fuse.Attr, inode uint64, entry *filer_pb.E
if entry.FileMode()&os.ModeSymlink != 0 {
out.Size = uint64(len(entry.Attributes.SymlinkTarget))
}
- out.Blocks = (out.Size + blockSize - 1) / blockSize
- setBlksize(out, blockSize)
- if entry == nil {
- return
- }
out.Mtime = uint64(entry.Attributes.Mtime)
out.Ctime = uint64(entry.Attributes.Mtime)
out.Atime = uint64(entry.Attributes.Mtime)