Delete expired attachments based on mod time instead of DB entry to avoid races
This commit is contained in:
parent
f992148d22
commit
916b09e22d
6 changed files with 65 additions and 43 deletions
|
@ -1125,8 +1125,9 @@ func (s *Server) updateStatsAndPrune() {
|
|||
log.Debug("Manager: Deleted %d stale visitor(s)", staleVisitors)
|
||||
|
||||
// Delete expired attachments
|
||||
if s.fileCache != nil {
|
||||
ids, err := s.messageCache.AttachmentsExpired()
|
||||
if s.fileCache != nil && s.config.AttachmentExpiryDuration > 0 {
|
||||
olderThan := time.Now().Add(-1 * s.config.AttachmentExpiryDuration)
|
||||
ids, err := s.fileCache.Expired(olderThan)
|
||||
if err != nil {
|
||||
log.Warn("Error retrieving expired attachments: %s", err.Error())
|
||||
} else if len(ids) > 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue