mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Fixes the re-generation of thumbnails making webp file, but named as PNG files
This commit is contained in:
parent
87322d7732
commit
7d9a9033f9
@ -1,6 +1,7 @@
|
||||
import logging
|
||||
import multiprocessing
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import tqdm
|
||||
from django import db
|
||||
@ -11,7 +12,7 @@ from ...parsers import get_parser_class_for_mime_type
|
||||
|
||||
|
||||
def _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):
|
||||
return
|
||||
|
||||
try:
|
||||
|
||||
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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user