mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Save edited PDF to temp file before replacing original
This commit is contained in:
		| @@ -542,9 +542,13 @@ def edit_pdf( | ||||
|                     dst.pages[-1].rotate(op["rotate"], relative=True) | ||||
|  | ||||
|         if update_document: | ||||
|             temp_path = doc.source_path.with_suffix(".tmp.pdf") | ||||
|             pdf = pdf_docs[0] | ||||
|             pdf.remove_unreferenced_resources() | ||||
|             pdf.save(doc.source_path) | ||||
|             # save the edited PDF to a temporary file in case of errors | ||||
|             pdf.save(temp_path) | ||||
|             # replace the original document with the edited one | ||||
|             temp_path.replace(doc.source_path) | ||||
|             doc.checksum = hashlib.md5(doc.source_path.read_bytes()).hexdigest() | ||||
|             doc.page_count = len(pdf.pages) | ||||
|             doc.save() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon