mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
fix dyn being serialized as bool
If you were running from git in the last ~30 hours, please load your collection using the latest git, review one card, then force a full upload to fix compatibility with other clients.
This commit is contained in:
parent
bbceeacf0b
commit
6e6776aab2
1 changed files with 18 additions and 11 deletions
|
@ -34,20 +34,27 @@ mod dynfix {
|
||||||
{
|
{
|
||||||
let mut map = Map::deserialize(deserializer)?;
|
let mut map = Map::deserialize(deserializer)?;
|
||||||
|
|
||||||
let is_dyn = map
|
let (is_dyn, needs_fix) = map
|
||||||
.get("dyn")
|
.get("dyn")
|
||||||
.ok_or_else(|| de::Error::missing_field("dyn"))
|
.ok_or_else(|| de::Error::missing_field("dyn"))
|
||||||
.map(|v| {
|
.and_then(|v| {
|
||||||
match v {
|
Ok(match v {
|
||||||
Value::Bool(b) => *b,
|
Value::Bool(b) => (*b, true),
|
||||||
Value::Number(n) => n.as_i64().unwrap_or(0) == 1,
|
Value::Number(n) => (n.as_i64().unwrap_or(0) == 1, false),
|
||||||
_ => {
|
_ => {
|
||||||
// invalid type, default to normal deck
|
// invalid type
|
||||||
false
|
return Err(de::Error::custom("dyn was wrong type"));
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
if needs_fix {
|
||||||
|
map.insert(
|
||||||
|
"dyn".into(),
|
||||||
|
Value::Number((if is_dyn { 1 } else { 0 }).into()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// remove some obsolete keys
|
// remove some obsolete keys
|
||||||
map.remove("separate");
|
map.remove("separate");
|
||||||
map.remove("return");
|
map.remove("return");
|
||||||
|
@ -79,8 +86,8 @@ pub struct DeckCommon {
|
||||||
collapsed: bool,
|
collapsed: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
desc: String,
|
desc: String,
|
||||||
#[serde(rename = "dyn", deserialize_with = "deserialize_bool_from_anything")]
|
#[serde(rename = "dyn")]
|
||||||
dynamic: bool,
|
dynamic: u8,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
other: HashMap<String, Value>,
|
other: HashMap<String, Value>,
|
||||||
}
|
}
|
||||||
|
@ -196,7 +203,7 @@ impl Default for NormalDeck {
|
||||||
desc: "".to_string(),
|
desc: "".to_string(),
|
||||||
today: Default::default(),
|
today: Default::default(),
|
||||||
other: Default::default(),
|
other: Default::default(),
|
||||||
dynamic: true,
|
dynamic: 0,
|
||||||
},
|
},
|
||||||
conf: 1,
|
conf: 1,
|
||||||
extend_new: 0,
|
extend_new: 0,
|
||||||
|
|
Loading…
Reference in a new issue