fix lints

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-20 00:03:07 -04:00 committed by June
parent fa942aedd7
commit f7e8054a00
5 changed files with 28 additions and 40 deletions

View file

@ -18,6 +18,7 @@ pub(crate) trait KeyValueDatabaseEngine: Send + Sync {
Self: Sized;
fn open_tree(&self, name: &'static str) -> Result<Arc<dyn KvTree>>;
fn flush(&self) -> Result<()>;
#[allow(dead_code)]
fn sync(&self) -> Result<()> { Ok(()) }
fn cleanup(&self) -> Result<()> { Ok(()) }
fn memory_usage(&self) -> Result<String> {
@ -27,13 +28,9 @@ pub(crate) trait KeyValueDatabaseEngine: Send + Sync {
#[allow(dead_code)]
fn clear_caches(&self) {}
fn backup(&self) -> Result<(), Box<dyn Error>> {
unimplemented!()
}
fn backup(&self) -> Result<(), Box<dyn Error>> { unimplemented!() }
fn backup_list(&self) -> Result<String> {
Ok(String::new())
}
fn backup_list(&self) -> Result<String> { Ok(String::new()) }
}
pub(crate) trait KvTree: Send + Sync {
@ -57,6 +54,8 @@ pub(crate) trait KvTree: Send + Sync {
}
fn remove(&self, key: &[u8]) -> Result<()>;
#[allow(dead_code)]
fn remove_batch(&self, iter: &mut dyn Iterator<Item = Vec<u8>>) -> Result<()> {
for key in iter {
self.remove(&key)?;

View file

@ -3,11 +3,8 @@ use std::{
pin::Pin,
sync::{Arc, RwLock},
};
use chrono::{
DateTime,
Utc,
};
use chrono::{DateTime, Utc};
use rust_rocksdb::{
backup::{BackupEngine, BackupEngineOptions},
LogLevel::{Debug, Error, Fatal, Info, Warn},
@ -80,8 +77,8 @@ fn db_options(
block_based_options.set_optimize_filters_for_memory(true);
block_based_options.set_cache_index_and_filter_blocks(true);
block_based_options.set_pin_top_level_index_and_filter(true);
block_based_options.set_block_cache(&col_cache);
db_opts.set_row_cache(&row_cache);
block_based_options.set_block_cache(col_cache);
db_opts.set_row_cache(row_cache);
// Buffers
db_opts.set_write_buffer_size(2 * 1024 * 1024);
@ -232,7 +229,7 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
return Ok(());
}
let options = BackupEngineOptions::new(&path.unwrap())?;
let options = BackupEngineOptions::new(path.unwrap())?;
let mut engine = BackupEngine::open(&options, &self.env)?;
let ret = if self.config.database_backups_to_keep > 0 {
match engine.create_new_backup_flush(&self.rocks, true) {
@ -242,9 +239,7 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
let info = &_info.last().unwrap();
info!(
"Created database backup #{} using {} bytes in {} files",
info.backup_id,
info.size,
info.num_files,
info.backup_id, info.size, info.num_files,
);
Ok(())
},
@ -270,18 +265,19 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
}
let mut res = String::new();
let options = BackupEngineOptions::new(&path.unwrap())?;
let options = BackupEngineOptions::new(path.unwrap())?;
let engine = BackupEngine::open(&options, &self.env)?;
for info in engine.get_backup_info() {
std::fmt::write(&mut res, format_args!(
std::fmt::write(
&mut res,
format_args!(
"#{} {}: {} bytes, {} files\n",
info.backup_id,
DateTime::<Utc>::from_timestamp(info.timestamp, 0)
.unwrap()
.to_rfc2822(),
DateTime::<Utc>::from_timestamp(info.timestamp, 0).unwrap().to_rfc2822(),
info.size,
info.num_files,
))
),
)
.unwrap();
}

View file

@ -273,11 +273,7 @@ lasttimelinecount_cache: {lasttimelinecount_cache}\n"
Ok(())
}
fn backup(&self) -> Result<(), Box<dyn std::error::Error>> {
self.db.backup()
}
fn backup(&self) -> Result<(), Box<dyn std::error::Error>> { self.db.backup() }
fn backup_list(&self) -> Result<String> {
self.db.backup_list()
}
fn backup_list(&self) -> Result<String> { self.db.backup_list() }
}

View file

@ -1878,11 +1878,9 @@ impl Service {
RoomMessageEventContent::text_plain(result)
},
ServerCommand::BackupDatabase => {
let mut result = tokio::task::spawn_blocking(move || {
match services().globals.db.backup() {
let mut result = tokio::task::spawn_blocking(move || match services().globals.db.backup() {
Ok(_) => String::new(),
Err(e) => (*e).to_string(),
}
})
.await
.unwrap();

View file

@ -1,5 +1,4 @@
use std::collections::BTreeMap;
use std::error::Error;
use std::{collections::BTreeMap, error::Error};
use async_trait::async_trait;
use ruma::{