Skip to content
Snippets Groups Projects
Commit ea3853ed authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Do not trigger save on every favicon get process

parent c6b1d66b
No related branches found
No related tags found
1 merge request!612Resolve "Favicon code regenerates favicons on every load"
Pipeline #11206 passed
......@@ -130,12 +130,23 @@ def get_or_create_favicon(title: str, default: str, is_favicon: bool = False) ->
"""Ensure that there is always a favicon object."""
from favicon.models import Favicon # noqa
favicon, created = Favicon.on_site.update_or_create(
favicon, created = Favicon.on_site.get_or_create(
title=title, defaults={"isFavicon": is_favicon}
)
changed = False
if favicon.isFavicon != is_favicon:
favicon.isFavicon = True
changed = True
if created:
favicon.faviconImage.save(os.path.basename(default), File(open(default, "rb")))
changed = True
if changed:
favicon.save()
return favicon
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment