mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Refactor: extract fn try_consume_file
The main purpose of this change is to make the following commits more readable.
This commit is contained in:
		| @@ -75,20 +75,22 @@ class Consumer: | |||||||
|         docs_old_to_new = sorted(docs, key=lambda doc: os.path.getmtime(doc)) |         docs_old_to_new = sorted(docs, key=lambda doc: os.path.getmtime(doc)) | ||||||
|  |  | ||||||
|         for doc in docs_old_to_new: |         for doc in docs_old_to_new: | ||||||
|  |             self.try_consume_file(doc) | ||||||
|  |  | ||||||
|  |     def try_consume_file(self, doc): | ||||||
|         doc = os.path.join(self.consume, doc) |         doc = os.path.join(self.consume, doc) | ||||||
|  |  | ||||||
|         if not os.path.isfile(doc): |         if not os.path.isfile(doc): | ||||||
|                 continue |             return | ||||||
|  |  | ||||||
|         if not re.match(FileInfo.REGEXES["title"], doc): |         if not re.match(FileInfo.REGEXES["title"], doc): | ||||||
|                 continue |             return | ||||||
|  |  | ||||||
|         if doc in self._ignore: |         if doc in self._ignore: | ||||||
|                 continue |             return | ||||||
|  |  | ||||||
|         if not self._is_ready(doc): |         if not self._is_ready(doc): | ||||||
|                 continue |             return | ||||||
|  |  | ||||||
|         if self._is_duplicate(doc): |         if self._is_duplicate(doc): | ||||||
|             self.log( |             self.log( | ||||||
| @@ -96,14 +98,14 @@ class Consumer: | |||||||
|                 "Skipping {} as it appears to be a duplicate".format(doc) |                 "Skipping {} as it appears to be a duplicate".format(doc) | ||||||
|             ) |             ) | ||||||
|             self._ignore.append(doc) |             self._ignore.append(doc) | ||||||
|                 continue |             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) |             self._ignore.append(doc) | ||||||
|                 continue |             return | ||||||
|  |  | ||||||
|         self.logging_group = uuid.uuid4() |         self.logging_group = uuid.uuid4() | ||||||
|  |  | ||||||
| @@ -132,7 +134,7 @@ class Consumer: | |||||||
|             self.log("error", "PARSE FAILURE for {}: {}".format(doc, e)) |             self.log("error", "PARSE FAILURE for {}: {}".format(doc, e)) | ||||||
|             parsed_document.cleanup() |             parsed_document.cleanup() | ||||||
|  |  | ||||||
|                 continue |             return | ||||||
|  |  | ||||||
|         else: |         else: | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Erik Arvstedt
					Erik Arvstedt