[bugfix/chore] oauth entropy fix + media cleanup tasks rewrite (#1853)

This commit is contained in:
kim
2023-06-22 20:46:36 +01:00
committed by GitHub
parent c4cf6326d8
commit 9a22102fa8
38 changed files with 2076 additions and 1090 deletions

View File

@@ -47,17 +47,19 @@ func (p *Processor) MediaRefetch(ctx context.Context, requestingAccount *gtsmode
return nil
}
// MediaPrune triggers a non-blocking prune of remote media, local unused media, etc.
// MediaPrune triggers a non-blocking prune of unused media, orphaned, uncaching remote and fixing cache states.
func (p *Processor) MediaPrune(ctx context.Context, mediaRemoteCacheDays int) gtserror.WithCode {
if mediaRemoteCacheDays < 0 {
err := fmt.Errorf("MediaPrune: invalid value for mediaRemoteCacheDays prune: value was %d, cannot be less than 0", mediaRemoteCacheDays)
return gtserror.NewErrorBadRequest(err, err.Error())
}
if err := p.mediaManager.PruneAll(ctx, mediaRemoteCacheDays, false); err != nil {
err = fmt.Errorf("MediaPrune: %w", err)
return gtserror.NewErrorInternalError(err)
}
// Start background task performing all media cleanup tasks.
go func() {
ctx := context.Background()
p.cleaner.Media().All(ctx, mediaRemoteCacheDays)
p.cleaner.Emoji().All(ctx)
}()
return nil
}