From dcb2597488867465a0d362bf9fc2b0a26a9e1672 Mon Sep 17 00:00:00 2001 From: Sandy Xu Date: Thu, 31 Aug 2023 16:31:11 +0800 Subject: [PATCH] meta: fix the issue that zero field of Format not applied in refreshSession --- pkg/meta/base.go | 6 ++++-- pkg/meta/config.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/meta/base.go b/pkg/meta/base.go index e23acdfd2b5d..76c595f0f3ed 100644 --- a/pkg/meta/base.go +++ b/pkg/meta/base.go @@ -242,14 +242,16 @@ func (m *baseMeta) Load(checkVersion bool) (*Format, error) { if err != nil { return nil, err } - if err = json.Unmarshal(body, &m.fmt); err != nil { + var format = new(Format) + if err = json.Unmarshal(body, format); err != nil { return nil, fmt.Errorf("json: %s", err) } if checkVersion { - if err = m.fmt.CheckVersion(); err != nil { + if err = format.CheckVersion(); err != nil { return nil, fmt.Errorf("check version: %s", err) } } + m.fmt = *format return &m.fmt, nil } diff --git a/pkg/meta/config.go b/pkg/meta/config.go index 36923ff58720..4d32806d43aa 100644 --- a/pkg/meta/config.go +++ b/pkg/meta/config.go @@ -60,7 +60,7 @@ type Format struct { Inodes uint64 `json:",omitempty"` EncryptKey string `json:",omitempty"` KeyEncrypted bool `json:",omitempty"` - TrashDays int `json:",omitempty"` + TrashDays int MetaVersion int `json:",omitempty"` MinClientVersion string `json:",omitempty"` MaxClientVersion string `json:",omitempty"`