| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Change get_or_create to update_or_create in parse_and_add_attachments() so that attachmentid and filename are refreshed when the mail archive re-indexes attachments. Previously, defaults were only applied on record creation, leaving stale IDs that pointed to non-existent attachments. Add regression tests verifying attachment metadata is updated correctly.
| Back | FazBrowse Home | New Git URL |
Fix stale attachment IDs causing broken links in Emails section
Root Cause:
parse_and_add_attachments() used get_or_create(), which only applies
defaults during object creation. When the PostgreSQL mail archive
re-indexes attachments and assigns new attachment IDs, existing
MailThreadAttachment records retained stale attachmentid values.
This resulted in attachment URLs pointing to non-existent resources (404).
Fix:
Replace get_or_create() with update_or_create() so that attachmentid
and filename are refreshed whenever attachment metadata changes.
This ensures:
Tests:
Add regression tests verifying:
All tests pass (41/41).
Lint and formatting checks pass.