Catch NaNs in FSRS weights

Users pasting in weights from the old scheduler were leaving the outer
square brackets in, causing the first and last numbers to be parsed as
NaN.
This commit is contained in:
Damien Elmes 2023-12-04 15:16:05 +10:00
parent cbab96ec75
commit 4e281026a0

View File

@ -145,7 +145,13 @@ impl Collection {
// add/update provided configs // add/update provided configs
for conf in &mut req.configs { for conf in &mut req.configs {
let weight_len = conf.inner.fsrs_weights.len(); let weight_len = conf.inner.fsrs_weights.len();
if weight_len != 0 && weight_len != 17 { if weight_len == 17 {
for i in 0..17 {
if !conf.inner.fsrs_weights[i].is_normal() {
return Err(AnkiError::FsrsWeightsInvalid);
}
}
} else if weight_len != 0 {
return Err(AnkiError::FsrsWeightsInvalid); return Err(AnkiError::FsrsWeightsInvalid);
} }
self.add_or_update_deck_config(conf)?; self.add_or_update_deck_config(conf)?;