From 0955d1b86aa5944342dd0e4ef711ed9f4c981fca Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 3 Apr 2025 13:58:25 +0100 Subject: [PATCH] remove unnecessary change --- internal/cache/copy.go | 42 ------------------------------------------ internal/cache/db.go | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 43 deletions(-) delete mode 100644 internal/cache/copy.go diff --git a/internal/cache/copy.go b/internal/cache/copy.go deleted file mode 100644 index ef7c9c96d..000000000 --- a/internal/cache/copy.go +++ /dev/null @@ -1,42 +0,0 @@ -// GoToSocial -// Copyright (C) GoToSocial Authors admin@gotosocial.org -// SPDX-License-Identifier: AGPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package cache - -import "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" - -func copyStatus(s1 *gtsmodel.Status) *gtsmodel.Status { - s2 := new(gtsmodel.Status) - *s2 = *s1 - - // Don't include ptr fields that - // will be populated separately. - // See internal/db/bundb/status.go. - s2.Account = nil - s2.InReplyTo = nil - s2.InReplyToAccount = nil - s2.BoostOf = nil - s2.BoostOfAccount = nil - s2.Poll = nil - s2.Attachments = nil - s2.Tags = nil - s2.Mentions = nil - s2.Emojis = nil - s2.CreatedWithApplication = nil - - return s2 -} diff --git a/internal/cache/db.go b/internal/cache/db.go index 146cf8dfb..7b9f94b4a 100644 --- a/internal/cache/db.go +++ b/internal/cache/db.go @@ -1312,6 +1312,28 @@ func (c *Caches) initStatus() { log.Infof(nil, "cache size = %d", cap) + copyF := func(s1 *gtsmodel.Status) *gtsmodel.Status { + s2 := new(gtsmodel.Status) + *s2 = *s1 + + // Don't include ptr fields that + // will be populated separately. + // See internal/db/bundb/status.go. + s2.Account = nil + s2.InReplyTo = nil + s2.InReplyToAccount = nil + s2.BoostOf = nil + s2.BoostOfAccount = nil + s2.Poll = nil + s2.Attachments = nil + s2.Tags = nil + s2.Mentions = nil + s2.Emojis = nil + s2.CreatedWithApplication = nil + + return s2 + } + c.DB.Status.Init(structr.CacheConfig[*gtsmodel.Status]{ Indices: []structr.IndexConfig{ {Fields: "ID"}, @@ -1323,7 +1345,7 @@ func (c *Caches) initStatus() { }, MaxSize: cap, IgnoreErr: ignoreErrors, - Copy: copyStatus, + Copy: copyF, Invalidate: c.OnInvalidateStatus, }) }