Avoid discrepancy when something goes wrong (e.g. one counter is decreased but not the other)
Notes
Use default_storage_class to get rid of the file on storage instead of letting the FileField media_file handle it.
As explained in the comments of this PR, attachment.media_file.delete() could rise to a race condition on counter update.
Description
Avoid discrepancy when something goes wrong (e.g. one counter is decreased but not the other)
Notes
Use
default_storage_class
to get rid of the file on storage instead of letting the FileFieldmedia_file
handle it. As explained in the comments of this PR,attachment.media_file.delete()
could rise to a race condition on counter update.