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()inhyperkitty/models/email.pyto delete the attachment file from disk and safely remove now-empty parent directories without touching the configured root folder. - Hooked up the
pre_deletesignal forAttachmentinhyperkitty/signals.pyso filesystem cleanup runs automatically on every attachment deletion. - Added regression test
test_delete_mailinglist_removes_local_attachment_filesinhyperkitty/tests/views/test_mailinglist.pyto 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).