mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-04 03:27:12 -05:00 
			
		
		
		
	Adds information system check for PNG thumbnail existence
This commit is contained in:
		
							parent
							
								
									34192349be
								
							
						
					
					
						commit
						12cdcf7681
					
				@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user