Skip to content

Commit

Permalink
don't crash when upgrading collection with ntid of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Aug 23, 2020
1 parent 2291f9a commit 1347650
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rslib/src/storage/notetype/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,13 @@ and ord in ",
pub(crate) fn upgrade_notetypes_to_schema15(&self) -> Result<()> {
let nts = self.get_schema11_notetypes()?;
let mut names = HashSet::new();
for (ntid, nt) in nts {
for (mut ntid, nt) in nts {
let mut nt = NoteType::from(nt);
// note types with id 0 found in the wild; assign a random ID
if ntid.0 == 0 {
ntid.0 = rand::random::<u32>().max(1) as i64;
nt.id = ntid;
}
nt.normalize_names();
nt.ensure_names_unique();
loop {
Expand Down

0 comments on commit 1347650

Please sign in to comment.