]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Handles the case where other might have a None field as well (#4598)
authorTrenton H <797416+stumpylog@users.noreply.github.com>
Thu, 16 Nov 2023 00:23:38 +0000 (16:23 -0800)
committerGitHub <noreply@github.com>
Thu, 16 Nov 2023 00:23:38 +0000 (16:23 -0800)
src/documents/data_models.py
src/paperless_mail/mail.py

index 7dcfe4401b73e140ee71df13f42a4cd2a46acf25..29a23fa7aa256bf997d1903fa09ad7bd86f4bf78 100644 (file)
@@ -48,31 +48,32 @@ class DocumentMetadataOverrides:
             self.storage_path_id = other.storage_path_id
         if self.owner_id is None:
             self.owner_id = other.owner_id
+
         # merge
-        # TODO: Handle the case where other is also None
         if self.tag_ids is None:
             self.tag_ids = other.tag_ids
-        else:
+        elif other.tag_ids is not None:
             self.tag_ids.extend(other.tag_ids)
+
         if self.view_users is None:
             self.view_users = other.view_users
-        else:
+        elif other.view_users is not None:
             self.view_users.extend(other.view_users)
+
         if self.view_groups is None:
             self.view_groups = other.view_groups
-        else:
+        elif other.view_groups is not None:
             self.view_groups.extend(other.view_groups)
+
         if self.change_users is None:
             self.change_users = other.change_users
-        else:
+        elif other.change_users is not None:
             self.change_users.extend(other.change_users)
+
         if self.change_groups is None:
             self.change_groups = other.change_groups
-        else:
-            self.change_groups = [
-                *self.change_groups,
-                *other.change_groups,
-            ]
+        elif other.change_groups is not None:
+            self.change_groups.extend(other.change_groups)
         return self
 
 
index f3ebc35dfbed433824c77dfd219b896f18794c57..2179b8c9082cfd541d7de166fe5ce478c0e9edc2 100644 (file)
@@ -617,7 +617,7 @@ class MailAccountHandler(LoggingMixin):
             f"{len(message.attachments)} attachment(s)",
         )
 
-        tag_ids = [tag.id for tag in rule.assign_tags.all()]
+        tag_ids: list[int] = [tag.id for tag in rule.assign_tags.all()]
         doc_type = rule.assign_document_type
 
         if (