mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Update rebuild_thumbnails command (#6254)
* Update rebuild_thumbnails command - Skip if images already exist - Prevents significant clutter in the logs - Speeds up the command too * Refactoring
This commit is contained in:
parent
8eec2f32c0
commit
716e577916
@ -4,6 +4,7 @@
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db.utils import OperationalError, ProgrammingError
|
||||
@ -26,6 +27,18 @@ class Command(BaseCommand):
|
||||
|
||||
img = model.image
|
||||
|
||||
# Check for image paths
|
||||
img_paths = []
|
||||
|
||||
for x in [model.image, model.image.thumbnail, model.image.preview]:
|
||||
if x and x.path:
|
||||
img_paths.append(x.path)
|
||||
|
||||
if len(img_paths) > 0:
|
||||
if all((os.path.exists(path) for path in img_paths)):
|
||||
# All images exist - skip further work
|
||||
return
|
||||
|
||||
logger.info("Generating thumbnail image for '%s'", img)
|
||||
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user