Fix attachment files not deleted from filesystem on archive/message deletionMaster

Closes #526

Problem

When mailing list archives or messages were deleted, attachment rows were removed from the database but the corresponding files stored under HYPERKITTY_ATTACHMENT_FOLDER remained on disk, causing orphaned files to accumulate indefinitely.

Changes

  • Added Attachment.on_pre_delete() in hyperkitty/models/email.py to delete the attachment file from disk and safely remove now-empty parent directories without touching the configured root folder.
  • Hooked up the pre_delete signal for Attachment in hyperkitty/signals.py so filesystem cleanup runs automatically on every attachment deletion.
  • Added regression test test_delete_mailinglist_removes_local_attachment_files in hyperkitty/tests/views/test_mailinglist.py to verify filesystem cleanup occurs when a mailing list archive is deleted.
  • Fixed CI lint warning W391 (trailing blank line) in touched files.

Testing

Existing test suite passes. New regression test covers the primary failure scenario (delete mailing list → attachment files removed from disk).

Merge request reports

Loading