diff --git a/engage.toml b/engage.toml index bd1e847c..b19b89c5 100644 --- a/engage.toml +++ b/engage.toml @@ -78,7 +78,19 @@ RUSTDOCFLAGS="-D warnings" cargo doc \ """ [[task]] -name = "cargo-clippy" +name = "clippy/default" +group = "lints" +script = """ +cargo clippy \ + --workspace \ + --all-targets \ + --color=always \ + -- \ + -D warnings +""" + +[[task]] +name = "clippy/all" group = "lints" script = """ cargo clippy \ @@ -90,6 +102,32 @@ cargo clippy \ -D warnings """ +[[task]] +name = "clippy/jemalloc" +group = "lints" +script = """ +cargo clippy \ + --workspace \ + --features jemalloc \ + --all-targets \ + --color=always \ + -- \ + -D warnings +""" + +[[task]] +name = "clippy/hardened_malloc" +group = "lints" +script = """ +cargo clippy \ + --workspace \ + --features hardened_malloc \ + --all-targets \ + --color=always \ + -- \ + -D warnings +""" + [[task]] name = "lychee" group = "lints" diff --git a/src/service/media/mod.rs b/src/service/media/mod.rs index 2622c5ca..e87889d3 100644 --- a/src/service/media/mod.rs +++ b/src/service/media/mod.rs @@ -476,66 +476,68 @@ impl Service { #[cfg(test)] mod tests { - use std::path::PathBuf; - - use base64::{engine::general_purpose, Engine as _}; - - use super::*; - - struct MockedKVDatabase; - - impl Data for MockedKVDatabase { - fn create_file_metadata( - &self, _sender_user: Option<&str>, mxc: String, width: u32, height: u32, content_disposition: Option<&str>, - content_type: Option<&str>, - ) -> Result> { - // copied from src/database/key_value/media.rs - let mut key = mxc.as_bytes().to_vec(); - key.push(0xFF); - key.extend_from_slice(&width.to_be_bytes()); - key.extend_from_slice(&height.to_be_bytes()); - key.push(0xFF); - key.extend_from_slice( - content_disposition - .as_ref() - .map(|f| f.as_bytes()) - .unwrap_or_default(), - ); - key.push(0xFF); - key.extend_from_slice( - content_type - .as_ref() - .map(|c| c.as_bytes()) - .unwrap_or_default(), - ); - - Ok(key) - } - - fn delete_file_mxc(&self, _mxc: String) -> Result<()> { todo!() } - - fn search_mxc_metadata_prefix(&self, _mxc: String) -> Result>> { todo!() } - - fn get_all_media_keys(&self) -> Result>> { todo!() } - - fn search_file_metadata( - &self, _mxc: String, _width: u32, _height: u32, - ) -> Result<(Option, Option, Vec)> { - todo!() - } - - fn remove_url_preview(&self, _url: &str) -> Result<()> { todo!() } - - fn set_url_preview(&self, _url: &str, _data: &UrlPreviewData, _timestamp: std::time::Duration) -> Result<()> { - todo!() - } - - fn get_url_preview(&self, _url: &str) -> Option { todo!() } - } - - #[tokio::test] #[cfg(feature = "sha256_media")] + #[tokio::test] async fn long_file_names_works() { + use std::path::PathBuf; + + use base64::{engine::general_purpose, Engine as _}; + + use super::*; + + struct MockedKVDatabase; + + impl Data for MockedKVDatabase { + fn create_file_metadata( + &self, _sender_user: Option<&str>, mxc: String, width: u32, height: u32, + content_disposition: Option<&str>, content_type: Option<&str>, + ) -> Result> { + // copied from src/database/key_value/media.rs + let mut key = mxc.as_bytes().to_vec(); + key.push(0xFF); + key.extend_from_slice(&width.to_be_bytes()); + key.extend_from_slice(&height.to_be_bytes()); + key.push(0xFF); + key.extend_from_slice( + content_disposition + .as_ref() + .map(|f| f.as_bytes()) + .unwrap_or_default(), + ); + key.push(0xFF); + key.extend_from_slice( + content_type + .as_ref() + .map(|c| c.as_bytes()) + .unwrap_or_default(), + ); + + Ok(key) + } + + fn delete_file_mxc(&self, _mxc: String) -> Result<()> { todo!() } + + fn search_mxc_metadata_prefix(&self, _mxc: String) -> Result>> { todo!() } + + fn get_all_media_keys(&self) -> Result>> { todo!() } + + fn search_file_metadata( + &self, _mxc: String, _width: u32, _height: u32, + ) -> Result<(Option, Option, Vec)> { + todo!() + } + + fn remove_url_preview(&self, _url: &str) -> Result<()> { todo!() } + + fn set_url_preview( + &self, _url: &str, _data: &UrlPreviewData, _timestamp: std::time::Duration, + ) -> Result<()> { + todo!() + } + + fn get_url_preview(&self, _url: &str) -> Option { todo!() } + } + static DB: MockedKVDatabase = MockedKVDatabase; let media = Service { db: &DB,