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).
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
// 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
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);