1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-05-28 09:25:37 +02:00

Expire attachments properly

This commit is contained in:
Philipp Heckel 2022-01-07 15:15:33 +01:00
parent c45a28e6af
commit e7c19a2bad
5 changed files with 101 additions and 14 deletions
server

View file

@ -832,6 +832,16 @@ func (s *Server) updateStatsAndPrune() {
}
}
// Delete expired attachments
ids, err := s.cache.AttachmentsExpired()
if err == nil {
if err := s.fileCache.Remove(ids); err != nil {
log.Printf("error while deleting attachments: %s", err.Error())
}
} else {
log.Printf("error retrieving expired attachments: %s", err.Error())
}
// Prune message cache
olderThan := time.Now().Add(-1 * s.config.CacheDuration)
if err := s.cache.Prune(olderThan); err != nil {