mozilla / addons

☂ Umbrella repository for Mozilla Addons ✨
Other
125 stars 41 forks source link

Source code tar.gz and tag.bz2 file extensions are broken by reupload #1864

Open ioanarusiczki opened 2 years ago

ioanarusiczki commented 2 years ago

STR:

  1. Upload a source code from dev hub for an addon version of .tar.gz or tar.bz2 format
  2. After changes are saved repeat the action, upload a tar.gz or tar.bz2 file again
  3. Click the view current link

Expected result: The file extension is tar.gz or tar.bz2

Actual result: there's a " _" followed by letters between tar and bz2

the extra hash

Notes: the content of the archive is not affected deleting that part _W1aheeg makes the archive re-usable for uploads.

cc diox

┆Issue is synchronized with this Jira Task

diox commented 2 years ago

This is because django storage class tries not to overwrite the existing file (https://github.com/django/django/blob/b626c5a9798b045b655d085d59efdd60b5d7a0e3/django/core/files/storage.py#L79-L83 and related code). Ultimately it works, as noted the content is not affected, but the filename gets messed up.

eviljeff commented 2 years ago

This seems to me to be a django bug really - it doesn't see .tar.bz2 as a file extension, only .bz2, when trying to generate an alternative name. It'd happen anywhere a filename like that was used (in our case only really with source code uploads though)

diox commented 2 years ago

Yeah. Ideally we should force an overwrite (need to use a custom storage class), though. We have no need for the old file.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this bug should stay open, please comment on the issue with further details. Thank you for your contributions.

KevinMind commented 4 months ago

Old Jira Ticket: https://mozilla-hub.atlassian.net/browse/ADDSRV-81