Fix deleting media with attachments.
If one deletes a media with attachments, there have been various problems: 1) If the file in the storage did not exist any more (maybe because due to a previous deletion attempt?), the error propagation failed, because the wrong thing was gathered. 2) The attachment database entries were not deleted. Using cascade for this, for now. Also add a simple unit test, that tests both by having a broken attachment on a media.
This commit is contained in:
@@ -145,6 +145,7 @@ class MediaEntry(Base, MediaEntryMixin):
|
||||
)
|
||||
|
||||
attachment_files_helper = relationship("MediaAttachmentFile",
|
||||
cascade="all, delete-orphan",
|
||||
order_by="MediaAttachmentFile.created"
|
||||
)
|
||||
attachment_files = association_proxy("attachment_files_helper", "dict_view",
|
||||
|
||||
Reference in New Issue
Block a user