mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Adds information system check for PNG thumbnail existence
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| # this is here so that django finds the checks. | ||||
| from .checks import changed_password_check | ||||
| from .checks import parser_check | ||||
| from .checks import png_thumbnail_check | ||||
|  | ||||
| __all__ = ["changed_password_check", "parser_check"] | ||||
| __all__ = ["changed_password_check", "parser_check", "png_thumbnail_check"] | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| import textwrap | ||||
| from pathlib import Path | ||||
|  | ||||
| from django.conf import settings | ||||
| from django.core.checks import Error | ||||
| from django.core.checks import Info | ||||
| from django.core.checks import register | ||||
| from django.core.exceptions import FieldError | ||||
| from django.db.utils import OperationalError | ||||
| @@ -11,7 +13,6 @@ from documents.signals import document_consumer_declaration | ||||
|  | ||||
| @register() | ||||
| def changed_password_check(app_configs, **kwargs): | ||||
|  | ||||
|     from documents.models import Document | ||||
|     from paperless.db import GnuPG | ||||
|  | ||||
| @@ -67,3 +68,23 @@ def parser_check(app_configs, **kwargs): | ||||
|         ] | ||||
|     else: | ||||
|         return [] | ||||
|  | ||||
|  | ||||
| @register() | ||||
| def png_thumbnail_check(app_configs, **kwargs): | ||||
|     from documents.models import Document | ||||
|  | ||||
|     try: | ||||
|         documents = Document.objects.all() | ||||
|         for document in documents: | ||||
|             existing_thumbnail = Path(document.thumbnail_path).resolve() | ||||
|             if existing_thumbnail.suffix == ".png": | ||||
|                 return [ | ||||
|                     Info( | ||||
|                         "PNG thumbnails found, consider running convert_thumbnails " | ||||
|                         "to convert to WebP", | ||||
|                     ), | ||||
|                 ] | ||||
|         return [] | ||||
|     except (OperationalError, ProgrammingError, FieldError): | ||||
|         return []  # No documents table yet | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Trenton Holmes
					Trenton Holmes