summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEmīls Piņķis <emils@mullvad.net>2019-03-05 12:33:46 +0000
committerEmīls Piņķis <emils@mullvad.net>2019-03-05 12:33:46 +0000
commitda05bb7c8189f8787aa7bccb9e8525d0ad486b83 (patch)
tree2012033f86e060588e2431320ec8c61a846ddc45
parent6bd6acc2f61f31a67f3dbd5091cf6cb287d6b78d (diff)
downloadmullvadvpn-da05bb7c8189f8787aa7bccb9e8525d0ad486b83.tar.xz
mullvadvpn-da05bb7c8189f8787aa7bccb9e8525d0ad486b83.zip
Fix deserialization of old account history
-rw-r--r--mullvad-daemon/src/account_history.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/mullvad-daemon/src/account_history.rs b/mullvad-daemon/src/account_history.rs
index e79356d257..b29640c13e 100644
--- a/mullvad-daemon/src/account_history.rs
+++ b/mullvad-daemon/src/account_history.rs
@@ -69,10 +69,16 @@ impl AccountHistory {
}
fn try_old_format(reader: &mut io::BufReader<fs::File>) -> Result<Vec<AccountToken>> {
+ #[derive(Deserialize)]
+ struct OldFormat {
+ accounts: Vec<AccountToken>,
+ }
reader
.seek(io::SeekFrom::Start(0))
.chain_err(|| ErrorKind::ReadError)?;
- Ok(serde_json::from_reader(reader).unwrap_or(vec![]))
+ Ok(serde_json::from_reader(reader)
+ .map(|old_format: OldFormat| old_format.accounts)
+ .unwrap_or(vec![]))
}
/// Gets account data for a certain account id and bumps it's entry to the top of the list if