some database code cleanups

This commit is contained in:
2026-03-05 15:47:23 -07:00
parent 1f450dcf14
commit 55c5c88c95
13 changed files with 137 additions and 137 deletions
+5 -5
View File
@@ -62,7 +62,7 @@ var globalPropMutex sync.Mutex
// Clone clones the entire global state.
func (g *Globals) Clone() *Globals {
rc := Globals{
rc := &Globals{
PostsPerPage: g.PostsPerPage,
OldPostsAtTop: g.OldPostsAtTop,
MaxSearchPage: g.MaxSearchPage,
@@ -73,7 +73,7 @@ func (g *Globals) Clone() *Globals {
CommunityCreateLevel: g.CommunityCreateLevel,
flags: nil,
}
return &rc
return rc
}
// Flags returns the global flags.
@@ -107,11 +107,11 @@ func AmGlobals(ctx context.Context) (*Globals, error) {
globalsMutex.Lock()
defer globalsMutex.Unlock()
if theGlobals == nil {
var g Globals
if err := amdb.GetContext(ctx, &g, "SELECT * FROM globals"); err != nil {
g := new(Globals)
if err := amdb.GetContext(ctx, g, "SELECT * FROM globals"); err != nil {
return nil, err
}
theGlobals = &g
theGlobals = g
}
return theGlobals, nil
}