mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Simplify ignoring docs
This commit is contained in:
		@@ -95,9 +95,11 @@ class Consumer:
 | 
				
			|||||||
        for file, mtime in files_old_to_new:
 | 
					        for file, mtime in files_old_to_new:
 | 
				
			||||||
            if mtime == os.path.getmtime(file):
 | 
					            if mtime == os.path.getmtime(file):
 | 
				
			||||||
                # File has not been modified and can be consumed
 | 
					                # File has not been modified and can be consumed
 | 
				
			||||||
                self.try_consume_file(file)
 | 
					                if not self.try_consume_file(file):
 | 
				
			||||||
 | 
					                    self._ignore.append(file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def try_consume_file(self, file):
 | 
					    def try_consume_file(self, file):
 | 
				
			||||||
 | 
					        "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
 | 
				
			||||||
@@ -109,15 +111,13 @@ class Consumer:
 | 
				
			|||||||
                "info",
 | 
					                "info",
 | 
				
			||||||
                "Skipping {} as it appears to be a duplicate".format(doc)
 | 
					                "Skipping {} as it appears to be a duplicate".format(doc)
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            self._ignore.append(doc)
 | 
					            return False
 | 
				
			||||||
            return
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        parser_class = self._get_parser_class(doc)
 | 
					        parser_class = self._get_parser_class(doc)
 | 
				
			||||||
        if not parser_class:
 | 
					        if not parser_class:
 | 
				
			||||||
            self.log(
 | 
					            self.log(
 | 
				
			||||||
                "error", "No parsers could be found for {}".format(doc))
 | 
					                "error", "No parsers could be found for {}".format(doc))
 | 
				
			||||||
            self._ignore.append(doc)
 | 
					            return False
 | 
				
			||||||
            return
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.logging_group = uuid.uuid4()
 | 
					        self.logging_group = uuid.uuid4()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -141,15 +141,10 @@ class Consumer:
 | 
				
			|||||||
                date
 | 
					                date
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        except ParseError as e:
 | 
					        except ParseError as e:
 | 
				
			||||||
 | 
					 | 
				
			||||||
            self._ignore.append(doc)
 | 
					 | 
				
			||||||
            self.log("error", "PARSE FAILURE for {}: {}".format(doc, e))
 | 
					            self.log("error", "PARSE FAILURE for {}: {}".format(doc, e))
 | 
				
			||||||
            parsed_document.cleanup()
 | 
					            parsed_document.cleanup()
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
            return
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
 | 
					 | 
				
			||||||
            parsed_document.cleanup()
 | 
					            parsed_document.cleanup()
 | 
				
			||||||
            self._cleanup_doc(doc)
 | 
					            self._cleanup_doc(doc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -163,6 +158,7 @@ class Consumer:
 | 
				
			|||||||
                document=document,
 | 
					                document=document,
 | 
				
			||||||
                logging_group=self.logging_group
 | 
					                logging_group=self.logging_group
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					            return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _get_parser_class(self, doc):
 | 
					    def _get_parser_class(self, doc):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user