Repository navigation
add 'recreate_previews' process_addons task - #8553
Conversation
| % (filename, instance.pk)) | ||
| storage.delete(filename) | ||
| if storage.exists(filename): | ||
| storage.delete(filename) |
There was a problem hiding this comment.
Django actually implies that check already and does os.path.exists itself in storage.delete
| preview = self.get_object() | ||
| assert 'png' in preview.thumbnail_path | ||
| assert 'png' in preview.image_path | ||
| assert 'png' in preview.original_path |
There was a problem hiding this comment.
nitpick, can we change these tests to assert preview.thumbnail_path.endswith('.png') to be a bit more failure-proof and make sure we actually have that as an ext of the filename.
| 'full': _size_tuple(700, 525) | ||
| 'thumb': _size_tuple(320, 200), | ||
| 'full': _size_tuple(1280, 800) | ||
| } |
There was a problem hiding this comment.
Should we add a comment where these sizes come from? An issue or a link to the frontend?
|
|
||
| @task | ||
| def recreate_previews(addon_pk, **kw): | ||
| log.info('[1@None] Recreating previews for addon: %s' % addon_pk) |
There was a problem hiding this comment.
What is this [1@None] prefix for?
There was a problem hiding this comment.
tbh, no idea. I lazily copied the log.info from the resize_preview method above.
| # We have an original size image, so we can resize that. | ||
| src = preview.original_path | ||
| (preview.sizes['image'], _) = resize_image( | ||
| src, preview.image_path, amo.ADDON_PREVIEW_SIZES['full']) |
There was a problem hiding this comment.
Note that we discussed this during the all hands: Make sure that we issue a blog post for developers to update/re-upload their screenshots if possible.
There was a problem hiding this comment.
#7908 is part of #7907 and that issue mentions Product will communicate changes.
| # use it for a new thumbnail | ||
| src = preview.image_path | ||
| # But we should resize the thumbnail regardless. | ||
| (preview.sizes['thumbnail'], _) = resize_image( |
There was a problem hiding this comment.
There's actually no need to wrap this in parenthesis.
| src, preview.thumbnail_path, amo.ADDON_PREVIEW_SIZES['thumb']) | ||
| preview.save() | ||
| except Exception as e: | ||
| log.error("Error saving preview: %s" % e) |
There was a problem hiding this comment.
Either use log.exception or set exc_info=True so that we get the proper stack-trace of what happened. Also, this is very generic, I'd rather have a list of things that we know can go wrong and report everything else directly to sentry.
There was a problem hiding this comment.
I'd imagine exceptions would fall into the rough buckets of "full size preview doesn't exist" and "full/original size preview is an invalid image somehow" but I'm not sure what we'd do with that information other than shrug and log. I suppose we could/should delete the Preview instance if that's happening?
There was a problem hiding this comment.
changed to log.exception in d002da8 but didn't delete the Preview instance.
Fixes mozilla/addons#5385