From 83a2c7d30f44020992bd946c6316eaf05c72e653 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:57:42 +0100 Subject: [PATCH] More comments --- roomserver/acls/acls.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/roomserver/acls/acls.go b/roomserver/acls/acls.go index 01e8820c..246342c9 100644 --- a/roomserver/acls/acls.go +++ b/roomserver/acls/acls.go @@ -39,8 +39,8 @@ type ServerACLs struct { } func NewServerACLs(db ServerACLDatabase) *ServerACLs { - // Add some logging, as this can take a while. - logrus.Infof("Loading server ACLs") + // Add some logging, as this can take a while on larger instances. + logrus.Infof("Loading server ACLs...") start := time.Now() aclCount := 0 defer func() { @@ -62,13 +62,16 @@ func NewServerACLs(db ServerACLDatabase) *ServerACLs { if err != nil { logrus.WithError(err).Fatalf("Failed to get known rooms") } - // For each room, let's see if we have a server ACL state event. If we - // do then we'll process it into memory so that we have the regexes to - // hand. + // No rooms with ACLs, don't bother hitting the DB again. + if len(rooms) == 0 { + return acls + } + + // Get ACLs for the required rooms, bail if we are unable to get them. events, err := db.GetBulkStateACLs(ctx, rooms) if err != nil { - logrus.WithError(err).Errorf("Failed to get server ACLs for all rooms: %q", err) + logrus.WithError(err).Fatal("Failed to get server ACLs for all rooms") } aclCount = len(events)