Delete expired attachments based on mod time instead of DB entry to avoid races
This commit is contained in:
parent
3e53d8a2c7
commit
10a9aca2a1
6 changed files with 65 additions and 43 deletions
|
@ -1116,8 +1116,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