Timo Kösters 2021-08-21 14:24:10 +02:00
parent 4956fb9fba
commit 3b78e43a18
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
2 changed files with 45 additions and 33 deletions

View File

@ -636,7 +636,11 @@ impl Database {
if db.globals.database_version()? < 9 { if db.globals.database_version()? < 9 {
// Update tokenids db layout // Update tokenids db layout
let batch = db.rooms.tokenids.iter().filter_map(|(key, _)| { let batch = db
.rooms
.tokenids
.iter()
.filter_map(|(key, _)| {
if !key.starts_with(b"!") { if !key.starts_with(b"!") {
return None; return None;
} }
@ -659,25 +663,33 @@ impl Database {
println!("old {:?}", key); println!("old {:?}", key);
println!("new {:?}", new_key); println!("new {:?}", new_key);
Some((new_key, Vec::new())) Some((new_key, Vec::new()))
}).collect::<Vec<_>>(); })
.collect::<Vec<_>>();
let mut iter = batch.into_iter().peekable(); let mut iter = batch.into_iter().peekable();
while iter.peek().is_some() { while iter.peek().is_some() {
db.rooms.tokenids.insert_batch(&mut iter.by_ref().take(1000))?; db.rooms
.tokenids
.insert_batch(&mut iter.by_ref().take(1000))?;
println!("smaller batch done"); println!("smaller batch done");
} }
println!("Deleting starts"); println!("Deleting starts");
let batch2 = db.rooms.tokenids.iter().filter_map(|(key, _)| { let batch2 = db
.rooms
.tokenids
.iter()
.filter_map(|(key, _)| {
if key.starts_with(b"!") { if key.starts_with(b"!") {
println!("del {:?}", key); println!("del {:?}", key);
Some(key) Some(key)
} else { } else {
None None
} }
}).collect::<Vec<_>>(); })
.collect::<Vec<_>>();
for key in batch2 { for key in batch2 {
println!("del"); println!("del");

View File

@ -912,7 +912,7 @@ pub async fn handle_incoming_pdu<'a>(
// Max limit reached // Max limit reached
warn!("Max prev event limit reached!"); warn!("Max prev event limit reached!");
graph.insert(prev_event_id.clone(), HashSet::new()); graph.insert(prev_event_id.clone(), HashSet::new());
continue continue;
} }
if let Some(json) = if let Some(json) =