From: Dessalines Date: Tue, 9 Nov 2021 22:31:28 +0000 (-0500) Subject: Fixing clippy X-Git-Url: http://these/git/%22https:/nerdica.net/%7B%24%7B%60data:application/static/%24%7B%60data:application/README.md?a=commitdiff_plain;h=f035af37383677ef9a4a5a9e48eb320c1cfa0573;p=lemmy.git Fixing clippy --- diff --git a/crates/apub_lib/src/object_id.rs b/crates/apub_lib/src/object_id.rs index 54643068..cf5dfaa1 100644 --- a/crates/apub_lib/src/object_id.rs +++ b/crates/apub_lib/src/object_id.rs @@ -25,7 +25,7 @@ lazy_static! { static ref CLIENT: Client = Client::builder() .user_agent(build_user_agent(&Settings::get())) .build() - .unwrap(); + .expect("Couldn't build client"); } /// We store Url on the heap because it is quite large (88 bytes). diff --git a/crates/apub_lib_derive/src/lib.rs b/crates/apub_lib_derive/src/lib.rs index 72e00fe2..d548af4c 100644 --- a/crates/apub_lib_derive/src/lib.rs +++ b/crates/apub_lib_derive/src/lib.rs @@ -56,7 +56,7 @@ pub fn derive_activity_handler(input: proc_macro::TokenStream) -> proc_macro::To .collect(); let attrs: &Vec = &attrs .first() - .unwrap() + .expect("Could not decode first attribute from token stream") .tokens .clone() .into_iter() diff --git a/src/main.rs b/src/main.rs index c078e786..059262a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,7 +65,7 @@ async fn main() -> Result<(), LemmyError> { let pool2 = pool.clone(); thread::spawn(move || { - scheduled_tasks::setup(pool2); + scheduled_tasks::setup(pool2).expect("Couldn't set up scheduled_tasks"); }); // Set up the rate limiter diff --git a/src/scheduled_tasks.rs b/src/scheduled_tasks.rs index 396c7b67..c3514d63 100644 --- a/src/scheduled_tasks.rs +++ b/src/scheduled_tasks.rs @@ -3,14 +3,15 @@ use clokwerk::{Scheduler, TimeUnits}; // Import week days and WeekDay use diesel::{sql_query, PgConnection, RunQueryDsl}; use lemmy_db_schema::{source::activity::Activity, DbPool}; +use lemmy_utils::LemmyError; use log::info; use std::{thread, time::Duration}; /// Schedules various cleanup tasks for lemmy in a background thread -pub fn setup(pool: DbPool) { +pub fn setup(pool: DbPool) -> Result<(), LemmyError> { let mut scheduler = Scheduler::new(); - let conn = pool.get().unwrap(); + let conn = pool.get()?; active_counts(&conn); // On startup, reindex the tables non-concurrently @@ -21,7 +22,7 @@ pub fn setup(pool: DbPool) { reindex_aggregates_tables(&conn, true); }); - let conn = pool.get().unwrap(); + let conn = pool.get()?; clear_old_activities(&conn); scheduler.every(1.weeks()).run(move || { clear_old_activities(&conn);