feat: Refactor media service to remove extracted EXIF data handling and update job payload with thumbnail path

This commit is contained in:
2025-11-15 15:06:03 +01:00
parent f7f1547592
commit faed54cb08
5 changed files with 50 additions and 48 deletions

View File

@@ -22,9 +22,11 @@ struct MediaJob {
media_id: Uuid,
}
//TODO: move this to a core crate and make sure that api uses it too, this will allow us to type safely pass messages
#[derive(Deserialize)]
struct MediaDeletedJob {
storage_path: String,
thumbnail_path: Option<String>,
}
#[tokio::main]
@@ -131,5 +133,12 @@ async fn process_deleted_job(
println!("Failed to delete XMP sidecar: {}", e);
}
if let Some(thumbnail_path) = payload.thumbnail_path {
let thumbnail_full_path = PathBuf::from(&context.media_library_path).join(thumbnail_path);
if let Err(e) = fs::remove_file(thumbnail_full_path).await {
println!("Failed to delete thumbnail: {}", e);
}
}
Ok(())
}

View File

@@ -5,7 +5,9 @@ use libertas_core::{
plugins::{MediaProcessorPlugin, PluginContext},
};
use crate::plugins::{thumbnail::ThumbnailPlugin, xmp_writer::XmpWriterPlugin};
use crate::plugins::{
exif_reader::ExifReaderPlugin, thumbnail::ThumbnailPlugin, xmp_writer::XmpWriterPlugin,
};
pub struct PluginManager {
plugins: Vec<Arc<dyn MediaProcessorPlugin>>,
@@ -15,7 +17,7 @@ impl PluginManager {
pub fn new() -> Self {
let mut plugins: Vec<Arc<dyn MediaProcessorPlugin>> = Vec::new();
// plugins.push(Arc::new(ExifReaderPlugin)); temporarily disabled due to duplicate metadata extraction (libertas_api already does this, needs refactor)
plugins.push(Arc::new(ExifReaderPlugin));
plugins.push(Arc::new(ThumbnailPlugin));
plugins.push(Arc::new(XmpWriterPlugin));