From ca5843aceac8189ac99d5122a02f0cb12411b2f0 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 24 Apr 2020 11:23:31 +1000 Subject: [PATCH] only compare to previous note type if it exists --- rslib/src/notetype/mod.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rslib/src/notetype/mod.rs b/rslib/src/notetype/mod.rs index dabef8b14..a9d73c0ab 100644 --- a/rslib/src/notetype/mod.rs +++ b/rslib/src/notetype/mod.rs @@ -239,10 +239,7 @@ impl Collection { nt.usn = self.usn()?; } self.transact(None, |col| { - if !preserve_usn { - let existing_notetype = col - .get_notetype(nt.id)? - .ok_or_else(|| AnkiError::invalid_input("no such notetype"))?; + if let Some(existing_notetype) = col.get_notetype(nt.id)? { col.update_notes_for_changed_fields(nt, existing_notetype.fields.len())?; col.update_cards_for_changed_templates(nt, existing_notetype.templates.len())?; }