mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 18:22:40 -04:00 
			
		
		
		
	In cases where a temporary file is created or used, copy the original file stats to it
This commit is contained in:
		
							parent
							
								
									36b4fff5c7
								
							
						
					
					
						commit
						883937bfd7
					
				| @ -180,6 +180,9 @@ class BarcodeReader: | |||||||
|         with scratch_image.open("rb") as img_file, self.pdf_file.open("wb") as pdf_file: |         with scratch_image.open("rb") as img_file, self.pdf_file.open("wb") as pdf_file: | ||||||
|             pdf_file.write(img2pdf.convert(img_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: |     def detect(self) -> None: | ||||||
|         """ |         """ | ||||||
|         Scan all pages of the PDF as images, updating barcodes and the pages |         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_filename |                 savepath = Path(self.temp_dir.name) / output_filename | ||||||
|                 with open(savepath, "wb") as out: |                 with open(savepath, "wb") as out: | ||||||
|                     dst.save(out) |                     dst.save(out) | ||||||
|  | 
 | ||||||
|  |                 shutil.copystat(self.file, savepath) | ||||||
|  | 
 | ||||||
|                 document_paths.append(savepath) |                 document_paths.append(savepath) | ||||||
| 
 | 
 | ||||||
|             return document_paths |             return document_paths | ||||||
|  | |||||||
| @ -326,7 +326,7 @@ class Consumer(LoggingMixin): | |||||||
|             dir=settings.SCRATCH_DIR, |             dir=settings.SCRATCH_DIR, | ||||||
|         ) |         ) | ||||||
|         self.path = Path(tempdir.name) / Path(self.filename) |         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. |         # Determine the parser class. | ||||||
| 
 | 
 | ||||||
| @ -582,6 +582,7 @@ class Consumer(LoggingMixin): | |||||||
|     def _write(self, storage_type, source, target): |     def _write(self, storage_type, source, target): | ||||||
|         with open(source, "rb") as read_file, open(target, "wb") as write_file: |         with open(source, "rb") as read_file, open(target, "wb") as write_file: | ||||||
|             write_file.write(read_file.read()) |             write_file.write(read_file.read()) | ||||||
|  |         shutil.copystat(source, target) | ||||||
| 
 | 
 | ||||||
|     def _log_script_outputs(self, completed_process: CompletedProcess): |     def _log_script_outputs(self, completed_process: CompletedProcess): | ||||||
|         """ |         """ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user