chore: delay message segments cleanup loop execution

This commit is contained in:
Patryk Osmaczko 2023-11-16 09:41:38 +01:00 committed by osmaczko
parent b6ade53603
commit dd5e45d81c
1 changed files with 3 additions and 2 deletions

View File

@ -5730,11 +5730,12 @@ func (m *Messenger) startMessageSegmentsCleanupLoop() {
logger := m.logger.Named("messageSegmentsCleanupLoop")
go func() {
var interval time.Duration = 0
// Delay by a few minutes to minimize messenger's startup time
var interval time.Duration = 5 * time.Minute
for {
select {
case <-time.After(interval):
// Immediate execution on first run, then set to regular interval
// Set the regular interval after the first execution
interval = 1 * time.Hour
err := m.sender.CleanupSegments()