From d058f6522efb6c949136a5bdcc5f2fd338331fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Sat, 21 Aug 2021 14:24:10 +0200 Subject: [PATCH] fmt --- src/database.rs | 76 +++++++++++++++++++++++++------------------- src/server_server.rs | 2 +- 2 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/database.rs b/src/database.rs index 23d3bdf9..3d1324e6 100644 --- a/src/database.rs +++ b/src/database.rs @@ -636,48 +636,60 @@ impl Database { if db.globals.database_version()? < 9 { // Update tokenids db layout - let batch = db.rooms.tokenids.iter().filter_map(|(key, _)| { - if !key.starts_with(b"!") { - return None; - } - let mut parts = key.splitn(4, |&b| b == 0xff); - let room_id = parts.next().unwrap(); - let word = parts.next().unwrap(); - let _pdu_id_room = parts.next().unwrap(); - let pdu_id_count = parts.next().unwrap(); + let batch = db + .rooms + .tokenids + .iter() + .filter_map(|(key, _)| { + if !key.starts_with(b"!") { + return None; + } + let mut parts = key.splitn(4, |&b| b == 0xff); + let room_id = parts.next().unwrap(); + let word = parts.next().unwrap(); + let _pdu_id_room = parts.next().unwrap(); + let pdu_id_count = parts.next().unwrap(); - let short_room_id = db - .rooms - .roomid_shortroomid - .get(&room_id) - .unwrap() - .expect("shortroomid should exist"); - let mut new_key = short_room_id; - new_key.extend_from_slice(word); - new_key.push(0xff); - new_key.extend_from_slice(pdu_id_count); - println!("old {:?}", key); - println!("new {:?}", new_key); - Some((new_key, Vec::new())) - }).collect::>(); + let short_room_id = db + .rooms + .roomid_shortroomid + .get(&room_id) + .unwrap() + .expect("shortroomid should exist"); + let mut new_key = short_room_id; + new_key.extend_from_slice(word); + new_key.push(0xff); + new_key.extend_from_slice(pdu_id_count); + println!("old {:?}", key); + println!("new {:?}", new_key); + Some((new_key, Vec::new())) + }) + .collect::>(); let mut iter = batch.into_iter().peekable(); 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!("Deleting starts"); - let batch2 = db.rooms.tokenids.iter().filter_map(|(key, _)| { - if key.starts_with(b"!") { - println!("del {:?}", key); - Some(key) - } else { - None - } - }).collect::>(); + let batch2 = db + .rooms + .tokenids + .iter() + .filter_map(|(key, _)| { + if key.starts_with(b"!") { + println!("del {:?}", key); + Some(key) + } else { + None + } + }) + .collect::>(); for key in batch2 { println!("del"); diff --git a/src/server_server.rs b/src/server_server.rs index 5b09872d..5299e1f0 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -912,7 +912,7 @@ pub async fn handle_incoming_pdu<'a>( // Max limit reached warn!("Max prev event limit reached!"); graph.insert(prev_event_id.clone(), HashSet::new()); - continue + continue; } if let Some(json) =