From 307866f7f564fa4b77069a1720c0a9f477834efc Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Sat, 4 Nov 2023 15:48:37 +0100 Subject: [PATCH] simplify BoltDB.Info code The new code does the same as the old one but doesn't call the checkFlag in case ReadOnly is already set based on age. --- backend/app/store/engine/bolt.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/app/store/engine/bolt.go b/backend/app/store/engine/bolt.go index 7aca3a05..3542eba5 100644 --- a/backend/app/store/engine/bolt.go +++ b/backend/app/store/engine/bolt.go @@ -306,9 +306,8 @@ func (b *BoltDB) Info(req InfoRequest) ([]store.PostInfo, error) { }) // set read-only from age and manual bucket - readOnlyAge := req.ReadOnlyAge - info.ReadOnly = readOnlyAge > 0 && !info.FirstTS.IsZero() && info.FirstTS.AddDate(0, 0, readOnlyAge).Before(time.Now()) - if b.checkFlag(FlagRequest{Locator: req.Locator, Flag: ReadOnly}) { + info.ReadOnly = req.ReadOnlyAge > 0 && !info.FirstTS.IsZero() && info.FirstTS.AddDate(0, 0, req.ReadOnlyAge).Before(time.Now()) + if !info.ReadOnly && b.checkFlag(FlagRequest{Locator: req.Locator, Flag: ReadOnly}) { info.ReadOnly = true } return []store.PostInfo{info}, err