A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
In cases where a temporary file is created or used, copy the original file stats to it
Trenton H883937bfd743
diff --git a/src/documents/barcodes.py b/src/documents/barcodes.pyindex 79fa2746f..dfeac545b 100644--- a/src/documents/barcodes.py+++ b/src/documents/barcodes.py@@ -180,6 +180,9 @@ class BarcodeReader:with scratch_image.open("rb") as img_file, self.pdf_file.open("wb") as pdf_file:pdf_file.write(img2pdf.convert(img_file))+ # Copy what file stat is possible+ shutil.copystat(self.file, self.pdf_file)+def detect(self) -> None:"""Scan all pages of the PDF as images, updating barcodes and the pages@@ -292,6 +295,9 @@ class BarcodeReader:savepath = Path(self.temp_dir.name) / output_filenamewith open(savepath, "wb") as out:dst.save(out)++ shutil.copystat(self.file, savepath)+document_paths.append(savepath)return document_pathsdiff --git a/src/documents/consumer.py b/src/documents/consumer.pyindex d6d3513ec..f2da2ff42 100644--- a/src/documents/consumer.py+++ b/src/documents/consumer.py@@ -326,7 +326,7 @@ class Consumer(LoggingMixin):dir=settings.SCRATCH_DIR,)self.path = Path(tempdir.name) / Path(self.filename)- shutil.copy(self.original_path, self.path)+ shutil.copy2(self.original_path, self.path)# Determine the parser class.@@ -582,6 +582,7 @@ class Consumer(LoggingMixin):def _write(self, storage_type, source, target):with open(source, "rb") as read_file, open(target, "wb") as write_file:write_file.write(read_file.read())+ shutil.copystat(source, target)def _log_script_outputs(self, completed_process: CompletedProcess):"""