v2api: Getattr: fix file size

This commit is contained in:
Jakob Unterwurzacher 2020-07-12 15:03:42 +02:00
parent 0d385846da
commit 4d99b02279

View File

@ -97,8 +97,22 @@ func (n *Node) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut)
if err != nil {
return fs.ToErrno(err)
}
n.rootNode().inoMap.TranslateStat(st)
// Fix inode number
rn := n.rootNode()
rn.inoMap.TranslateStat(st)
out.Attr.FromStat(st)
// Fix size
if out.IsRegular() {
out.Size = rn.contentEnc.CipherSizeToPlainSize(out.Size)
} else if out.IsSymlink() {
target, _ := n.Readlink(ctx)
out.Size = uint64(len(target))
}
if rn.args.ForceOwner != nil {
out.Owner = *rn.args.ForceOwner
}
return 0
}