Repository navigation
Cachebust icons with their hash - #7608
Conversation
…UG is True
Without that change, if DEBUG is True, we end up with:
<div class="{{ undefined value printed: the inline if-expression on line 95
in 'devhub/addons/forms_shared/media.html' evaluated to false and no else
section was defined. }}">
And that messes up the style in that form, enough to change the widths
of the columns, pushing the add-on preview on the right outside of the
container.
7c7029c to
7104a01
Compare
| {% endif %} | ||
|
|
||
| <div class="{{ 'edit-previews-submit' if context == 'submit' }}"> | ||
| <div {{ 'class="edit-previews-submit"' if context == 'submit' else '' }}> |
| # Store the original hash, we'll return it to update the corresponding | ||
| # add-on. | ||
| with open(source) as fd: | ||
| icon_hash = hashlib.md5(fd.read()).hexdigest()[:8] |
There was a problem hiding this comment.
I'm not sure I'm a fan of this even though there's a good chance that this is unique enough and we have the icon-name as another factor. Maybe just a comment about the logic here and why the first bits are enough would suffice. As far as I know md5 hashes are relatively evenly distributed so we probably won't run into problems for many thousand icons to come. I wouldn't go much higher than that though. I wonder why we have that limitation? Bandwidth, storage?
There was a problem hiding this comment.
I could go further but I don't really see the point, IMHO that wastes storage space - this will only be an issue if the same add-on changes their icon and somehow the hexadecimal representation of the md5 of their new icon has the same first 8 chars. Icon changes are rare enough in the first place... ending up with such a similar md5 seems extremely unlikely.
There was a problem hiding this comment.
I do agree, let's document that though.
|
Will land after the tag |
Fix mozilla/addons#3095