fix SQLite bug when migrating database from 1 to 2 (#136)
parent
8903604caa
commit
b7de9cdc47
|
@ -21,7 +21,11 @@ pub struct NatTraverse<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NatTraverse<'a> {
|
impl<'a> NatTraverse<'a> {
|
||||||
pub fn new(interface: &'a InterfaceName, backend: Backend, diffs: &[PeerDiff]) -> Result<Self, Error> {
|
pub fn new(
|
||||||
|
interface: &'a InterfaceName,
|
||||||
|
backend: Backend,
|
||||||
|
diffs: &[PeerDiff],
|
||||||
|
) -> Result<Self, Error> {
|
||||||
let mut remaining: Vec<_> = diffs.iter().filter_map(|diff| diff.new).cloned().collect();
|
let mut remaining: Vec<_> = diffs.iter().filter_map(|diff| diff.new).cloned().collect();
|
||||||
|
|
||||||
for peer in &mut remaining {
|
for peer in &mut remaining {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::ServerError;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rusqlite::{params, types::Type, Connection};
|
use rusqlite::{params, types::Type, Connection};
|
||||||
use shared::{Endpoint, Peer, PeerContents, PERSISTENT_KEEPALIVE_INTERVAL_SECS};
|
use shared::{Peer, PeerContents, PERSISTENT_KEEPALIVE_INTERVAL_SECS};
|
||||||
use std::{
|
use std::{
|
||||||
net::IpAddr,
|
net::IpAddr,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
|
@ -240,10 +240,14 @@ impl DatabasePeer {
|
||||||
let invite_expires = row
|
let invite_expires = row
|
||||||
.get::<_, Option<u64>>(9)?
|
.get::<_, Option<u64>>(9)?
|
||||||
.map(|unixtime| SystemTime::UNIX_EPOCH + Duration::from_secs(unixtime));
|
.map(|unixtime| SystemTime::UNIX_EPOCH + Duration::from_secs(unixtime));
|
||||||
let candidates_str: String = row.get(10)?;
|
|
||||||
let candidates: Vec<Endpoint> = serde_json::from_str(&candidates_str).map_err(|_| {
|
let candidates = if let Some(candidates) = row.get::<_, Option<String>>(10)? {
|
||||||
|
serde_json::from_str(&candidates).map_err(|_| {
|
||||||
rusqlite::Error::InvalidColumnType(10, "candidates (json)".into(), Type::Text)
|
rusqlite::Error::InvalidColumnType(10, "candidates (json)".into(), Type::Text)
|
||||||
})?;
|
})?
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
};
|
||||||
|
|
||||||
let persistent_keepalive_interval = Some(PERSISTENT_KEEPALIVE_INTERVAL_SECS);
|
let persistent_keepalive_interval = Some(PERSISTENT_KEEPALIVE_INTERVAL_SECS);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue