mirror of
https://github.com/chatmail/core.git
synced 2026-04-22 16:06:30 +03:00
Fix cargo clippy and doc errors after Rust update to 1.66
This commit is contained in:
@@ -746,7 +746,7 @@ mod tests {
|
||||
assert!(file_size(&avatar_blob).await <= 3000);
|
||||
assert!(file_size(&avatar_blob).await > 2000);
|
||||
tokio::task::block_in_place(move || {
|
||||
let img = image::open(&avatar_blob).unwrap();
|
||||
let img = image::open(avatar_blob).unwrap();
|
||||
assert!(img.width() > 130);
|
||||
assert_eq!(img.width(), img.height());
|
||||
});
|
||||
|
||||
10
src/chat.rs
10
src/chat.rs
@@ -768,7 +768,7 @@ impl ChatId {
|
||||
paramsv![self],
|
||||
)
|
||||
.await?;
|
||||
Ok(count as usize)
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
pub async fn get_fresh_msg_cnt(self, context: &Context) -> Result<usize> {
|
||||
@@ -793,7 +793,7 @@ impl ChatId {
|
||||
paramsv![MessageState::InFresh, self],
|
||||
)
|
||||
.await?;
|
||||
Ok(count as usize)
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
pub(crate) async fn get_param(self, context: &Context) -> Result<Params> {
|
||||
@@ -1474,7 +1474,7 @@ impl Chat {
|
||||
new_rfc724_mid,
|
||||
self.id,
|
||||
ContactId::SELF,
|
||||
to_id as i32,
|
||||
to_id,
|
||||
timestamp,
|
||||
msg.viewtype,
|
||||
msg.state,
|
||||
@@ -1522,7 +1522,7 @@ impl Chat {
|
||||
new_rfc724_mid,
|
||||
self.id,
|
||||
ContactId::SELF,
|
||||
to_id as i32,
|
||||
to_id,
|
||||
timestamp,
|
||||
msg.viewtype,
|
||||
msg.state,
|
||||
@@ -3261,7 +3261,7 @@ pub(crate) async fn get_chat_cnt(context: &Context) -> Result<usize> {
|
||||
paramsv![],
|
||||
)
|
||||
.await?;
|
||||
Ok(count as usize)
|
||||
Ok(count)
|
||||
} else {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ impl Context {
|
||||
let value = match key {
|
||||
Config::Selfavatar => {
|
||||
let rel_path = self.sql.get_raw_config(key.as_ref()).await?;
|
||||
rel_path.map(|p| get_abs_path(self, &p).to_string_lossy().into_owned())
|
||||
rel_path.map(|p| get_abs_path(self, p).to_string_lossy().into_owned())
|
||||
}
|
||||
Config::SysVersion => Some((*DC_VERSION_STR).clone()),
|
||||
Config::SysMsgsizeMaxRecommended => Some(format!("{}", RECOMMENDED_FILE_SIZE)),
|
||||
|
||||
@@ -855,7 +855,7 @@ impl Contact {
|
||||
paramsv![ContactId::LAST_SPECIAL],
|
||||
)
|
||||
.await?;
|
||||
Ok(count as usize)
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
/// Get blocked contacts.
|
||||
|
||||
@@ -528,10 +528,10 @@ impl Context {
|
||||
let l2 = LoginParam::load_configured_params(self).await?;
|
||||
let secondary_addrs = self.get_secondary_self_addrs().await?.join(", ");
|
||||
let displayname = self.get_config(Config::Displayname).await?;
|
||||
let chats = get_chat_cnt(self).await? as usize;
|
||||
let unblocked_msgs = message::get_unblocked_msg_cnt(self).await as usize;
|
||||
let request_msgs = message::get_request_msg_cnt(self).await as usize;
|
||||
let contacts = Contact::get_real_cnt(self).await? as usize;
|
||||
let chats = get_chat_cnt(self).await?;
|
||||
let unblocked_msgs = message::get_unblocked_msg_cnt(self).await;
|
||||
let request_msgs = message::get_request_msg_cnt(self).await;
|
||||
let contacts = Contact::get_real_cnt(self).await?;
|
||||
let is_configured = self.get_config_int(Config::Configured).await?;
|
||||
let socks5_enabled = self.get_config_int(Config::Socks5Enabled).await?;
|
||||
let dbversion = self
|
||||
|
||||
@@ -20,7 +20,7 @@ struct Dehtml {
|
||||
/// increased at each `<div>` and decreased at each `</div>`. This way we know when the quote ends.
|
||||
/// If this is > `0`, then we are inside a `<div name="quote">`
|
||||
divs_since_quote_div: u32,
|
||||
/// Everything between <div name="quote"> and <div name="quoted-content"> is usually metadata
|
||||
/// Everything between `<div name="quote">` and `<div name="quoted-content">` is usually metadata
|
||||
/// If this is > `0`, then we are inside a `<div name="quoted-content">`.
|
||||
divs_since_quoted_content_div: u32,
|
||||
/// All-Inkl just puts the quote into `<blockquote> </blockquote>`. This count is
|
||||
@@ -42,7 +42,7 @@ impl Dehtml {
|
||||
}
|
||||
fn get_add_text(&self) -> AddText {
|
||||
if self.divs_since_quote_div > 0 && self.divs_since_quoted_content_div == 0 {
|
||||
AddText::No // Everything between <div name="quoted"> and <div name="quoted_content"> is metadata which we don't want
|
||||
AddText::No // Everything between `<div name="quoted">` and `<div name="quoted_content">` is metadata which we don't want
|
||||
} else {
|
||||
self.add_text
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ impl HtmlMsgParser {
|
||||
/// Convert a mime part to a data: url as defined in [RFC 2397](https://tools.ietf.org/html/rfc2397).
|
||||
fn mimepart_to_data_url(mail: &mailparse::ParsedMail<'_>) -> Result<String> {
|
||||
let data = mail.get_body_raw()?;
|
||||
let data = base64::encode(&data);
|
||||
let data = base64::encode(data);
|
||||
Ok(format!("data:{};base64,{}", mail.ctype.mimetype, data))
|
||||
}
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ pub(crate) async fn perform_job(context: &Context, mut connection: Connection<'_
|
||||
info!(
|
||||
context,
|
||||
"job #{} not succeeded on try #{}, retry in {} seconds.",
|
||||
job.job_id as u32,
|
||||
job.job_id,
|
||||
tries,
|
||||
time_offset
|
||||
);
|
||||
|
||||
@@ -74,7 +74,7 @@ pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone {
|
||||
|
||||
/// Serialise the key to a base64 string.
|
||||
fn to_base64(&self) -> String {
|
||||
base64::encode(&DcKey::to_bytes(self))
|
||||
base64::encode(DcKey::to_bytes(self))
|
||||
}
|
||||
|
||||
/// Serialise the key to ASCII-armored representation.
|
||||
|
||||
@@ -579,8 +579,8 @@ impl Message {
|
||||
|
||||
pub fn has_deviating_timestamp(&self) -> bool {
|
||||
let cnv_to_local = gm2local_offset();
|
||||
let sort_timestamp = self.get_sort_timestamp() as i64 + cnv_to_local;
|
||||
let send_timestamp = self.get_timestamp() as i64 + cnv_to_local;
|
||||
let sort_timestamp = self.get_sort_timestamp() + cnv_to_local;
|
||||
let send_timestamp = self.get_timestamp() + cnv_to_local;
|
||||
|
||||
sort_timestamp / 86400 != send_timestamp / 86400
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ pub enum Param {
|
||||
/// For Chats
|
||||
Selftalk = b'K',
|
||||
|
||||
/// For Chats: On sending a new message we set the subject to "Re: <last subject>".
|
||||
/// For Chats: On sending a new message we set the subject to `Re: <last subject>`.
|
||||
/// Usually we just use the subject of the parent message, but if the parent message
|
||||
/// is deleted, we use the LastSubject of the chat.
|
||||
LastSubject = b't',
|
||||
|
||||
10
src/sql.rs
10
src/sql.rs
@@ -236,13 +236,13 @@ impl Sql {
|
||||
// When auto_vacuum is INCREMENTAL, it is possible to
|
||||
// use PRAGMA incremental_vacuum to return unused
|
||||
// database pages to the filesystem.
|
||||
conn.pragma_update(None, "auto_vacuum", &"INCREMENTAL".to_string())?;
|
||||
conn.pragma_update(None, "auto_vacuum", "INCREMENTAL".to_string())?;
|
||||
|
||||
// journal_mode is persisted, it is sufficient to change it only for one handle.
|
||||
conn.pragma_update(None, "journal_mode", &"WAL".to_string())?;
|
||||
conn.pragma_update(None, "journal_mode", "WAL".to_string())?;
|
||||
|
||||
// Default synchronous=FULL is much slower. NORMAL is sufficient for WAL mode.
|
||||
conn.pragma_update(None, "synchronous", &"NORMAL".to_string())?;
|
||||
conn.pragma_update(None, "synchronous", "NORMAL".to_string())?;
|
||||
Ok(())
|
||||
})?;
|
||||
}
|
||||
@@ -459,7 +459,7 @@ impl Sql {
|
||||
let conn = self.get_conn().await?;
|
||||
tokio::task::block_in_place(move || {
|
||||
let mut exists = false;
|
||||
conn.pragma(None, "table_info", &name.to_string(), |_row| {
|
||||
conn.pragma(None, "table_info", name.to_string(), |_row| {
|
||||
// will only be executed if the info was found
|
||||
exists = true;
|
||||
Ok(())
|
||||
@@ -476,7 +476,7 @@ impl Sql {
|
||||
let mut exists = false;
|
||||
// `PRAGMA table_info` returns one row per column,
|
||||
// each row containing 0=cid, 1=name, 2=type, 3=notnull, 4=dflt_value
|
||||
conn.pragma(None, "table_info", &table_name.to_string(), |row| {
|
||||
conn.pragma(None, "table_info", table_name.to_string(), |row| {
|
||||
let curr_name: String = row.get(1)?;
|
||||
if col_name == curr_name {
|
||||
exists = true;
|
||||
|
||||
@@ -273,7 +273,7 @@ async fn maybe_warn_on_outdated(context: &Context, now: i64, approx_compile_time
|
||||
/// IDs generated by this function are 66 bit wide and are returned as 11 base64 characters.
|
||||
///
|
||||
/// Additional information when used as a message-id or group-id:
|
||||
/// - for OUTGOING messages this ID is written to the header as `Chat-Group-ID:` and is added to the message ID as Gr.<grpid>.<random>@<random>
|
||||
/// - for OUTGOING messages this ID is written to the header as `Chat-Group-ID:` and is added to the message ID as `Gr.<grpid>.<random>@<random>`
|
||||
/// - for INCOMING messages, the ID is taken from the Chat-Group-ID-header or from the Message-ID in the In-Reply-To: or References:-Header
|
||||
/// - the group-id should be a string with the characters [a-zA-Z0-9\-_]
|
||||
pub(crate) fn create_id() -> String {
|
||||
@@ -361,7 +361,7 @@ pub(crate) fn get_abs_path(context: &Context, path: impl AsRef<Path>) -> PathBuf
|
||||
pub(crate) async fn get_filebytes(context: &Context, path: impl AsRef<Path>) -> u64 {
|
||||
let path_abs = get_abs_path(context, &path);
|
||||
match fs::metadata(&path_abs).await {
|
||||
Ok(meta) => meta.len() as u64,
|
||||
Ok(meta) => meta.len(),
|
||||
Err(_err) => 0,
|
||||
}
|
||||
}
|
||||
@@ -494,7 +494,7 @@ pub fn open_file_std<P: AsRef<std::path::Path>>(
|
||||
let p: PathBuf = path.as_ref().into();
|
||||
let path_abs = get_abs_path(context, p);
|
||||
|
||||
match std::fs::File::open(&path_abs) {
|
||||
match std::fs::File::open(path_abs) {
|
||||
Ok(bytes) => Ok(bytes),
|
||||
Err(err) => {
|
||||
warn!(
|
||||
|
||||
Reference in New Issue
Block a user