Check if mimetype handler exists in delete_related_files signal handler.

Review Request #13512 — Created Jan. 31, 2024 and submitted

Information

Review Board
master

Reviewers

File attachments recently gained the ability to delete related files
when the main file is deleted. This can include things like images
deleting thumbnail versions, or Office documents deleting PDF copies.

This new code wasn't checking if the mimetype_handler existed, which
meant if we ended up with an attachment that didn't have a mimetype
specified, it would crash.

Was able to delete file attachments that didn't have the mimetype
field set.

Summary ID
Check if mimetype handler exists in delete_related_files signal handler.
File attachments recently gained the ability to delete related files when the main file is deleted. This can include things like images deleting thumbnail versions, or Office documents deleting PDF copies. This new code wasn't checking if the mimetype_handler existed, which meant if we ended up with an attachment that didn't have a mimetype specified, it would crash. Testing Done: Was able to delete file attachments that didn't have the `mimetype` field set.
07f8144dc77862f1650530759740a382e4d6e8d9
Description From Last Updated

Now that we're accessing instance.mimetype_handler twice, we could pull it out into a variable.

maubinmaubin
maubin
  1. Now I wish I had named the function delete_related_files instead of delete_associated_files. Has a more natural sound to it :P.

  2. reviewboard/attachments/signal_handlers.py (Diff revision 1)
     
     
     
    Show all issues

    Now that we're accessing instance.mimetype_handler twice, we could pull it out into a variable.

  3. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-7.x (c0ba4b8)
Loading...