resolve and add even more pedantic clippy lints
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
0bb5115bd1
commit
3bc2af7d26
32 changed files with 167 additions and 167 deletions
|
@ -95,7 +95,6 @@ fn db_options(
|
|||
|
||||
// Compression
|
||||
let rocksdb_compression_algo = match config.rocksdb_compression_algo.as_ref() {
|
||||
"zstd" => rust_rocksdb::DBCompressionType::Zstd,
|
||||
"zlib" => rust_rocksdb::DBCompressionType::Zlib,
|
||||
"lz4" => rust_rocksdb::DBCompressionType::Lz4,
|
||||
"bz2" => rust_rocksdb::DBCompressionType::Bz2,
|
||||
|
@ -247,7 +246,7 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
|
|||
let ret = if self.config.database_backups_to_keep > 0 {
|
||||
match engine.create_new_backup_flush(&self.rocks, true) {
|
||||
Err(e) => return Err(Box::new(e)),
|
||||
Ok(_) => {
|
||||
Ok(()) => {
|
||||
let _info = engine.get_backup_info();
|
||||
let info = &_info.last().unwrap();
|
||||
info!(
|
||||
|
@ -435,7 +434,7 @@ impl KvTree for RocksDbEngineTree<'_> {
|
|||
let lock = self.write_lock.write().unwrap();
|
||||
|
||||
let old = self.db.rocks.get_cf_opt(&self.cf(), key, &readoptions)?;
|
||||
let new = utils::increment(old.as_deref()).unwrap();
|
||||
let new = utils::increment(old.as_deref());
|
||||
self.db.rocks.put_cf_opt(&self.cf(), key, &new, &writeoptions)?;
|
||||
|
||||
drop(lock);
|
||||
|
@ -458,7 +457,7 @@ impl KvTree for RocksDbEngineTree<'_> {
|
|||
|
||||
for key in iter {
|
||||
let old = self.db.rocks.get_cf_opt(&self.cf(), &key, &readoptions)?;
|
||||
let new = utils::increment(old.as_deref()).unwrap();
|
||||
let new = utils::increment(old.as_deref());
|
||||
batch.put_cf(&self.cf(), key, new);
|
||||
}
|
||||
|
||||
|
|
|
@ -263,12 +263,11 @@ lasttimelinecount_cache: {lasttimelinecount_cache}\n"
|
|||
.server_signingkeys
|
||||
.get(origin.as_bytes())?
|
||||
.and_then(|bytes| serde_json::from_slice(&bytes).ok())
|
||||
.map(|keys: ServerSigningKeys| {
|
||||
.map_or_else(BTreeMap::new, |keys: ServerSigningKeys| {
|
||||
let mut tree = keys.verify_keys;
|
||||
tree.extend(keys.old_verify_keys.into_iter().map(|old| (old.0, VerifyKey::new(old.1.key))));
|
||||
tree
|
||||
})
|
||||
.unwrap_or_else(BTreeMap::new);
|
||||
});
|
||||
|
||||
Ok(signingkeys)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ impl service::pusher::Data for KeyValueDatabase {
|
|||
let mut key = sender.as_bytes().to_vec();
|
||||
key.push(0xFF);
|
||||
key.extend_from_slice(ids.pushkey.as_bytes());
|
||||
self.senderkey_pusher.remove(&key).map(|_| ()).map_err(Into::into)
|
||||
self.senderkey_pusher.remove(&key).map_err(Into::into)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,12 +24,9 @@ impl service::rooms::user::Data for KeyValueDatabase {
|
|||
userroom_id.push(0xFF);
|
||||
userroom_id.extend_from_slice(room_id.as_bytes());
|
||||
|
||||
self.userroomid_notificationcount
|
||||
.get(&userroom_id)?
|
||||
.map(|bytes| {
|
||||
utils::u64_from_bytes(&bytes).map_err(|_| Error::bad_database("Invalid notification count in db."))
|
||||
})
|
||||
.unwrap_or(Ok(0))
|
||||
self.userroomid_notificationcount.get(&userroom_id)?.map_or(Ok(0), |bytes| {
|
||||
utils::u64_from_bytes(&bytes).map_err(|_| Error::bad_database("Invalid notification count in db."))
|
||||
})
|
||||
}
|
||||
|
||||
fn highlight_count(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
|
||||
|
@ -37,12 +34,9 @@ impl service::rooms::user::Data for KeyValueDatabase {
|
|||
userroom_id.push(0xFF);
|
||||
userroom_id.extend_from_slice(room_id.as_bytes());
|
||||
|
||||
self.userroomid_highlightcount
|
||||
.get(&userroom_id)?
|
||||
.map(|bytes| {
|
||||
utils::u64_from_bytes(&bytes).map_err(|_| Error::bad_database("Invalid highlight count in db."))
|
||||
})
|
||||
.unwrap_or(Ok(0))
|
||||
self.userroomid_highlightcount.get(&userroom_id)?.map_or(Ok(0), |bytes| {
|
||||
utils::u64_from_bytes(&bytes).map_err(|_| Error::bad_database("Invalid highlight count in db."))
|
||||
})
|
||||
}
|
||||
|
||||
fn last_notification_read(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
|
||||
|
|
|
@ -125,7 +125,7 @@ impl service::users::Data for KeyValueDatabase {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the avatar_url of a user.
|
||||
/// Get the `avatar_url` of a user.
|
||||
fn avatar_url(&self, user_id: &UserId) -> Result<Option<OwnedMxcUri>> {
|
||||
self.userid_avatarurl
|
||||
.get(user_id.as_bytes())?
|
||||
|
@ -324,13 +324,10 @@ impl service::users::Data for KeyValueDatabase {
|
|||
}
|
||||
|
||||
fn last_one_time_keys_update(&self, user_id: &UserId) -> Result<u64> {
|
||||
self.userid_lastonetimekeyupdate
|
||||
.get(user_id.as_bytes())?
|
||||
.map(|bytes| {
|
||||
utils::u64_from_bytes(&bytes)
|
||||
.map_err(|_| Error::bad_database("Count in roomid_lastroomactiveupdate is invalid."))
|
||||
})
|
||||
.unwrap_or(Ok(0))
|
||||
self.userid_lastonetimekeyupdate.get(user_id.as_bytes())?.map_or(Ok(0), |bytes| {
|
||||
utils::u64_from_bytes(&bytes)
|
||||
.map_err(|_| Error::bad_database("Count in roomid_lastroomactiveupdate is invalid."))
|
||||
})
|
||||
}
|
||||
|
||||
fn take_one_time_key(
|
||||
|
@ -817,7 +814,7 @@ impl KeyValueDatabase {}
|
|||
|
||||
/// Will only return with Some(username) if the password was not empty and the
|
||||
/// username could be successfully parsed.
|
||||
/// If utils::string_from_bytes(...) returns an error that username will be
|
||||
/// If `utils::string_from_bytes`(...) returns an error that username will be
|
||||
/// skipped and the error will be logged.
|
||||
fn get_username_with_valid_password(username: &[u8], password: &[u8]) -> Option<String> {
|
||||
// A valid password is not empty
|
||||
|
|
|
@ -120,8 +120,8 @@ pub struct KeyValueDatabase {
|
|||
pub(super) roomsynctoken_shortstatehash: Arc<dyn KvTree>,
|
||||
/// Remember the state hash at events in the past.
|
||||
pub(super) shorteventid_shortstatehash: Arc<dyn KvTree>,
|
||||
/// StateKey = EventType + StateKey, ShortStateKey = Count
|
||||
pub(super) statekey_shortstatekey: Arc<dyn KvTree>,
|
||||
pub(super) statekey_shortstatekey: Arc<dyn KvTree>, /* StateKey = EventType + StateKey, ShortStateKey =
|
||||
* Count */
|
||||
pub(super) shortstatekey_statekey: Arc<dyn KvTree>,
|
||||
|
||||
pub(super) roomid_shortroomid: Arc<dyn KvTree>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue