diff --git a/InvenTree/InvenTree/management/commands/rebuild_thumbnails.py b/InvenTree/InvenTree/management/commands/rebuild_thumbnails.py index 8b54c98cc7..72512f6e44 100644 --- a/InvenTree/InvenTree/management/commands/rebuild_thumbnails.py +++ b/InvenTree/InvenTree/management/commands/rebuild_thumbnails.py @@ -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: