Skip to content

Commit

Permalink
simplify BoltDB.Info code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
paskal authored and umputun committed Nov 4, 2023
1 parent 19e1616 commit 307866f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions backend/app/store/engine/bolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 307866f

Please sign in to comment.