move media startup into service

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-13 07:05:51 +00:00
parent 38c989a07e
commit aa7a310200
2 changed files with 8 additions and 1 deletions

View file

@ -3,6 +3,7 @@ mod tests;
use std::{collections::HashMap, io::Cursor, num::Saturating as Sat, path::PathBuf, sync::Arc, time::SystemTime};
use async_trait::async_trait;
use base64::{engine::general_purpose, Engine as _};
use conduit::{checked, debug, debug_error, error, utils, Error, Result, Server};
use data::Data;
@ -47,6 +48,7 @@ pub struct Service {
pub url_preview_mutex: RwLock<HashMap<String, Arc<Mutex<()>>>>,
}
#[async_trait]
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
@ -56,6 +58,12 @@ impl crate::Service for Service {
}))
}
async fn worker(self: Arc<Self>) -> Result<()> {
self.create_media_dir().await?;
Ok(())
}
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
}

View file

@ -93,7 +93,6 @@ impl Services {
pub(super) async fn start(&self) -> Result<()> {
debug_info!("Starting services...");
self.media.create_media_dir().await?;
globals::migrations::migrations(&self.db, &self.globals.config).await?;
globals::emerg_access::init_emergency_access();