Add new complete strategy

This commit is contained in:
Joachim 2022-01-08 17:41:44 +01:00
parent f141777d52
commit a54995eb9d
2 changed files with 15 additions and 1 deletions

View file

@ -191,7 +191,7 @@ USER_AGENT = f"{agent} (BookWyrm/{VERSION}; +https://{DOMAIN}/)"
ENABLE_THUMBNAIL_GENERATION = env.bool("ENABLE_THUMBNAIL_GENERATION", False)
IMAGEKIT_CACHEFILE_DIR = "thumbnails"
#IMAGEKIT_DEFAULT_CACHEFILE_BACKEND = "imagekit.cachefiles.backends.Celery"
IMAGEKIT_DEFAULT_CACHEFILE_STRATEGY = "imagekit.cachefiles.strategies.Optimistic"
IMAGEKIT_DEFAULT_CACHEFILE_STRATEGY = "bookwyrm.thumbnail_generation.Strategy"
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

View file

@ -0,0 +1,14 @@
class Strategy:
"""
A strategy that generates the image on source saved (Optimistic),
but also on demand, for old images (JustInTime).
"""
def on_source_saved(self, file):
file.generate()
def on_existence_required(self, file):
file.generate()
def on_content_required(self, file):
file.generate()