From f035af37383677ef9a4a5a9e48eb320c1cfa0573 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 9 Nov 2021 17:31:28 -0500 Subject: [PATCH] Fixing clippy --- crates/apub_lib/src/object_id.rs | 2 +- crates/apub_lib_derive/src/lib.rs | 2 +- src/main.rs | 2 +- src/scheduled_tasks.rs | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/apub_lib/src/object_id.rs b/crates/apub_lib/src/object_id.rs index 546430685..cf5dfaa1e 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 72e00fe2b..d548af4c4 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 c078e7860..059262a03 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 396c7b675..c3514d63e 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);