Use the original file for the checksum, not the maybe alpha removed version

This commit is contained in:
Trenton Holmes 2023-12-02 08:22:55 -08:00 committed by Trenton H
parent aff56077a8
commit a451b5167b
2 changed files with 20 additions and 17 deletions

View File

@ -519,7 +519,11 @@ class Consumer(LoggingMixin):
document.filename = generate_unique_filename(document) document.filename = generate_unique_filename(document)
create_source_path_directory(document.source_path) create_source_path_directory(document.source_path)
self._write(document.storage_type, self.path, document.source_path) self._write(
document.storage_type,
self.original_path,
document.source_path,
)
self._write( self._write(
document.storage_type, document.storage_type,
@ -711,7 +715,6 @@ class Consumer(LoggingMixin):
storage_type = Document.STORAGE_TYPE_UNENCRYPTED storage_type = Document.STORAGE_TYPE_UNENCRYPTED
with open(self.path, "rb") as f:
document = Document.objects.create( document = Document.objects.create(
title=( title=(
self._parse_title_placeholders(self.override_title) self._parse_title_placeholders(self.override_title)
@ -720,7 +723,7 @@ class Consumer(LoggingMixin):
)[:127], )[:127],
content=text, content=text,
mime_type=mime_type, mime_type=mime_type,
checksum=hashlib.md5(f.read()).hexdigest(), checksum=hashlib.md5(self.original_path.read_bytes()).hexdigest(),
created=create_date, created=create_date,
modified=create_date, modified=create_date,
storage_type=storage_type, storage_type=storage_type,

View File

@ -105,7 +105,7 @@ def get_supported_file_extensions() -> set[str]:
return extensions return extensions
def get_parser_class_for_mime_type(mime_type: str) -> Optional["DocumentParser"]: def get_parser_class_for_mime_type(mime_type: str) -> Optional[type["DocumentParser"]]:
""" """
Returns the best parser (by weight) for the given mimetype or Returns the best parser (by weight) for the given mimetype or
None if no parser exists None if no parser exists