Skip to content

Cachebust icons with their hash - #7608

Merged
diox merged 3 commits into
mozilla:masterfrom
diox:cachebust-icons-with-their-hash
Feb 21, 2018
Merged

diox merged 3 commits into
mozilla:masterfrom
diox:cachebust-icons-with-their-hash

Conversation

@diox

@diox diox commented Feb 20, 2018

Copy link
Copy Markdown
Member

diox added 2 commits February 19, 2018 17:29
…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.
@diox
diox force-pushed the cachebust-icons-with-their-hash branch from 7c7029c to 7104a01 Compare February 20, 2018 11:27
@diox
diox requested a review from EnTeQuAk February 20, 2018 12:16
{% endif %}

<div class="{{ 'edit-previews-submit' if context == 'submit' }}">
<div {{ 'class="edit-previews-submit"' if context == 'submit' else '' }}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

# 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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree, let's document that though.

@diox

diox commented Feb 20, 2018

Copy link
Copy Markdown
Member Author

Will land after the tag

@diox
diox merged commit 09b83b9 into mozilla:master Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate hash for cachebusting add-on icons instead of relying on modification date

2 participants