mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-04 03:27:12 -05:00 
			
		
		
		
	Wrap document consumption in a transaction #262
This commit is contained in:
		
							parent
							
								
									b5176d207e
								
							
						
					
					
						commit
						14bb52b6a4
					
				@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					from django.db import transaction
 | 
				
			||||||
import datetime
 | 
					import datetime
 | 
				
			||||||
import hashlib
 | 
					import hashlib
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
@ -111,8 +112,11 @@ class Consumer:
 | 
				
			|||||||
                if not self.try_consume_file(file):
 | 
					                if not self.try_consume_file(file):
 | 
				
			||||||
                    self._ignore.append((file, mtime))
 | 
					                    self._ignore.append((file, mtime))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @transaction.atomic
 | 
				
			||||||
    def try_consume_file(self, file):
 | 
					    def try_consume_file(self, file):
 | 
				
			||||||
        "Return True if file was consumed"
 | 
					        """
 | 
				
			||||||
 | 
					        Return True if file was consumed
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if not re.match(FileInfo.REGEXES["title"], file):
 | 
					        if not re.match(FileInfo.REGEXES["title"], file):
 | 
				
			||||||
            return False
 | 
					            return False
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user