summaryrefslogtreecommitdiff
path: root/internal/cleaner
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-11-10 13:07:34 +0100
committerLibravatar tobi <tobi.smethurst@protonmail.com>2025-11-17 14:14:57 +0100
commitc61b89fd413b3a8f3782981509d21186bef82a1f (patch)
tree503bc2d83cf7d5ea35ef974ec2c5ae9050a3a074 /internal/cleaner
parent[chore] update dependencies (#4547) (diff)
downloadgotosocial-c61b89fd413b3a8f3782981509d21186bef82a1f.tar.xz
[performance] remove hard reliance on .Cached field to indicate whether media / emoji is cached (#4545)
This removes our hard reliance on the `.Cached` field of media and emojis to determine whether it exists in storage. We still make use of it as a useful flag to know whether to even bother checking storage, but we ultimately rely on the `ErrNotFound` response of storage to determine whether the media exists and needs recaching. This now removes our hard reliance on performing the `FixCacheStatus()` cleanup operations for media and emojis, which should reduce a whole bunch of S3 storage driver calls (thus, reducing cost for metered S3 buckets). Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4545 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/cleaner')
-rw-r--r--internal/cleaner/cleaner.go4
-rw-r--r--internal/cleaner/emoji.go8
-rw-r--r--internal/cleaner/media.go8
3 files changed, 16 insertions, 4 deletions
diff --git a/internal/cleaner/cleaner.go b/internal/cleaner/cleaner.go
index 7e32566ee..ab9a1867e 100644
--- a/internal/cleaner/cleaner.go
+++ b/internal/cleaner/cleaner.go
@@ -141,8 +141,8 @@ func (c *Cleaner) ScheduleJobs() error {
)
}
- // Time travel from
- // year zero, groovy.
+ // Time travel from the
+ // year zero, groovy baby.
firstCleanupAt := time.Date(
now.Year(),
now.Month(),
diff --git a/internal/cleaner/emoji.go b/internal/cleaner/emoji.go
index 245dfac27..e72ee9665 100644
--- a/internal/cleaner/emoji.go
+++ b/internal/cleaner/emoji.go
@@ -41,10 +41,16 @@ func (e *Emoji) All(ctx context.Context, maxRemoteDays int) {
e.LogUncacheRemote(ctx, t)
e.LogFixBroken(ctx)
e.LogPruneUnused(ctx)
- e.LogFixCacheStates(ctx)
_ = e.state.Storage.Storage.Clean(ctx)
}
+// AllAndFix calls LogFixCacheStates(), followed by All(), it
+// is done this way round so Storage.Clean() is performed last.
+func (e *Emoji) AllAndFix(ctx context.Context, maxRemoteDays int) {
+ e.LogFixCacheStates(ctx)
+ e.All(ctx, maxRemoteDays)
+}
+
// LogUncacheRemote performs Emoji.UncacheRemote(...), logging the start and outcome.
func (e *Emoji) LogUncacheRemote(ctx context.Context, olderThan time.Time) {
log.Infof(ctx, "start older than: %s", olderThan.Format(time.Stamp))
diff --git a/internal/cleaner/media.go b/internal/cleaner/media.go
index 99fd5779f..bd02cb2a3 100644
--- a/internal/cleaner/media.go
+++ b/internal/cleaner/media.go
@@ -44,10 +44,16 @@ func (m *Media) All(ctx context.Context, maxRemoteDays int) {
m.LogUncacheRemote(ctx, t)
m.LogPruneOrphaned(ctx)
m.LogPruneUnused(ctx)
- m.LogFixCacheStates(ctx)
_ = m.state.Storage.Storage.Clean(ctx)
}
+// AllAndFix calls LogFixCacheStates(), followed by All(), it
+// is done this way round so Storage.Clean() is performed last.
+func (m *Media) AllAndFix(ctx context.Context, maxRemoteDays int) {
+ m.LogFixCacheStates(ctx)
+ m.All(ctx, maxRemoteDays)
+}
+
// LogUncacheRemote performs Media.UncacheRemote(...), logging the start and outcome.
func (m *Media) LogUncacheRemote(ctx context.Context, olderThan time.Time) {
log.Infof(ctx, "start older than: %s", olderThan.Format(time.Stamp))