mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	locking for the document archiver
This commit is contained in:
		@@ -11,6 +11,7 @@ from django import db
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.core.management.base import BaseCommand
 | 
			
		||||
from django.db import transaction
 | 
			
		||||
from filelock import FileLock
 | 
			
		||||
from whoosh.writing import AsyncWriter
 | 
			
		||||
 | 
			
		||||
from documents.models import Document
 | 
			
		||||
@@ -47,8 +48,10 @@ def handle_document(document_id):
 | 
			
		||||
                    archive_checksum=checksum,
 | 
			
		||||
                    content=parser.get_text()
 | 
			
		||||
                )
 | 
			
		||||
                create_source_path_directory(document.archive_path)
 | 
			
		||||
                shutil.move(parser.get_archive_path(), document.archive_path)
 | 
			
		||||
                with FileLock(settings.MEDIA_LOCK):
 | 
			
		||||
                    create_source_path_directory(document.archive_path)
 | 
			
		||||
                    shutil.move(parser.get_archive_path(),
 | 
			
		||||
                                document.archive_path)
 | 
			
		||||
 | 
			
		||||
        with AsyncWriter(index.open_index()) as writer:
 | 
			
		||||
            index.update_document(writer, document)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user