From ab8c2f1e5e3d395def2d1d9f4ac9f6ab7924516e Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sat, 11 Apr 2020 09:35:06 +0200 Subject: [PATCH] Rename pduid_pdus to pduid_pdu --- src/data.rs | 12 ++++++------ src/database.rs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/data.rs b/src/data.rs index 583a986d..b26b899c 100644 --- a/src/data.rs +++ b/src/data.rs @@ -189,7 +189,7 @@ impl Data { prefix.extend_from_slice(room_id.to_string().as_bytes()); prefix.push(b'#'); // Add delimiter so we don't find rooms starting with the same id - if let Some((key, _)) = self.db.pduid_pdus.get_gt(&prefix).unwrap() { + if let Some((key, _)) = self.db.pduid_pdu.get_gt(&prefix).unwrap() { if key.starts_with(&prefix) { true } else { @@ -238,7 +238,7 @@ impl Data { serde_json::from_slice( &self .db - .pduid_pdus + .pduid_pdu .get(pdu_id) .unwrap() .expect("eventid_pduid in db is valid"), @@ -340,7 +340,7 @@ impl Data { let index = utils::u64_from_bytes( &self .db - .pduid_pdus + .pduid_pdu .update_and_fetch(&count_key, utils::increment) .unwrap() .unwrap(), @@ -353,7 +353,7 @@ impl Data { pdu_id.extend_from_slice(&index.to_be_bytes()); self.db - .pduid_pdus + .pduid_pdu .insert(&pdu_id, &*serde_json::to_string(&pdu).unwrap()) .unwrap(); @@ -375,7 +375,7 @@ impl Data { utils::u64_from_bytes( &self .db - .pduid_pdus + .pduid_pdu .get(&count_key) .unwrap() .unwrap_or_else(|| (&0_u64.to_be_bytes()).into()), @@ -394,7 +394,7 @@ impl Data { let mut current = prefix.clone(); current.extend_from_slice(&since.to_be_bytes()); - while let Some((key, value)) = self.db.pduid_pdus.get_gt(¤t).unwrap() { + while let Some((key, value)) = self.db.pduid_pdu.get_gt(¤t).unwrap() { if key.starts_with(&prefix) { current = key.to_vec(); pdus.push(serde_json::from_slice(&value).expect("pdu in db is valid")); diff --git a/src/database.rs b/src/database.rs index f17e76fd..7a308614 100644 --- a/src/database.rs +++ b/src/database.rs @@ -57,7 +57,7 @@ pub struct Database { pub userid_avatarurl: sled::Tree, pub deviceid_token: sled::Tree, pub token_userid: sled::Tree, - pub pduid_pdus: sled::Tree, + pub pduid_pdu: sled::Tree, // PduId = RoomId + Since pub eventid_pduid: sled::Tree, pub roomid_pduleaves: MultiValue, pub roomid_userids: MultiValue, @@ -92,7 +92,7 @@ impl Database { userid_avatarurl: db.open_tree("userid_avatarurl").unwrap(), deviceid_token: db.open_tree("deviceid_token").unwrap(), token_userid: db.open_tree("token_userid").unwrap(), - pduid_pdus: db.open_tree("pduid_pdus").unwrap(), + pduid_pdu: db.open_tree("pduid_pdu").unwrap(), eventid_pduid: db.open_tree("eventid_pduid").unwrap(), roomid_pduleaves: MultiValue(db.open_tree("roomid_pduleaves").unwrap()), roomid_userids: MultiValue(db.open_tree("roomid_userids").unwrap()), @@ -174,8 +174,8 @@ impl Database { String::from_utf8_lossy(&v), ); } - println!("\n# PDU Id -> PDUs:"); - for (k, v) in self.pduid_pdus.iter().map(|r| r.unwrap()) { + println!("\n# PDU Id -> PDU:"); + for (k, v) in self.pduid_pdu.iter().map(|r| r.unwrap()) { println!( "{:?} -> {:?}", String::from_utf8_lossy(&k),