A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fixes the re-generation of thumbnails making webp file, but named as PNG files
Trenton Holmes7d9a9033f93c
diff --git a/src/documents/management/commands/document_thumbnails.py b/src/documents/management/commands/document_thumbnails.pyindex c9928c7cc..595d8ba3b 100644--- a/src/documents/management/commands/document_thumbnails.py+++ b/src/documents/management/commands/document_thumbnails.py@@ -1,6 +1,7 @@import loggingimport multiprocessingimport shutil+from pathlib import Pathimport tqdmfrom django import db@@ -11,7 +12,7 @@ from ...parsers import get_parser_class_for_mime_typedef _process_document(doc_in):- document = Document.objects.get(id=doc_in)+ document: Document = Document.objects.get(id=doc_in)parser_class = get_parser_class_for_mime_type(document.mime_type)if parser_class:@@ -21,6 +22,13 @@ def _process_document(doc_in):returntry:++ existing_thumbnail = Path(document.thumbnail_path).resolve()++ # Remove an existing PNG format thumbnail, if it existed+ if existing_thumbnail.exists() and existing_thumbnail.suffix == ".png":+ existing_thumbnail.unlink()+thumb = parser.get_optimised_thumbnail(document.source_path,document.mime_type,@@ -69,7 +77,7 @@ class Command(BaseCommand):ids = [doc.id for doc in documents]# Note to future self: this prevents django from reusing database- # conncetions between processes, which is bad and does not work+ # connections between processes, which is bad and does not work# with postgres.db.connections.close_all()