diff --git a/mediarepo-daemon/mediarepo-logic/src/dao/file/add.rs b/mediarepo-daemon/mediarepo-logic/src/dao/file/add.rs index d7a16c3..e3be978 100644 --- a/mediarepo-daemon/mediarepo-logic/src/dao/file/add.rs +++ b/mediarepo-daemon/mediarepo-logic/src/dao/file/add.rs @@ -5,6 +5,7 @@ use sea_orm::ActiveValue::Set; use sea_orm::{ActiveModelTrait, DatabaseTransaction, TransactionTrait}; use mediarepo_core::error::RepoResult; +use mediarepo_core::thumbnailer::ThumbnailSize; use mediarepo_database::entities::{content_descriptor, file, file_metadata}; use crate::dao::file::FileDao; @@ -44,8 +45,11 @@ impl FileDao { .await?; trx.commit().await?; + let dto = FileDto::new(file, cd, Some(metadata)); + self.create_thumbnails(&dto, vec![ThumbnailSize::Medium]) + .await?; - Ok(FileDto::new(file, cd, Some(metadata))) + Ok(dto) } } diff --git a/mediarepo-daemon/mediarepo-logic/src/dao/file/update.rs b/mediarepo-daemon/mediarepo-logic/src/dao/file/update.rs index f47d333..184bf1b 100644 --- a/mediarepo-daemon/mediarepo-logic/src/dao/file/update.rs +++ b/mediarepo-daemon/mediarepo-logic/src/dao/file/update.rs @@ -58,7 +58,7 @@ impl FileDao { #[tracing::instrument(level = "debug", skip(self))] pub async fn create_thumbnails + Debug>( &self, - file: FileDto, + file: &FileDto, sizes: I, ) -> RepoResult> { let bytes = self.get_bytes(file.cd()).await?; diff --git a/mediarepo-daemon/mediarepo-logic/src/dao/job/generate_missing_thumbnails.rs b/mediarepo-daemon/mediarepo-logic/src/dao/job/generate_missing_thumbnails.rs index edc84d9..e4f9899 100644 --- a/mediarepo-daemon/mediarepo-logic/src/dao/job/generate_missing_thumbnails.rs +++ b/mediarepo-daemon/mediarepo-logic/src/dao/job/generate_missing_thumbnails.rs @@ -19,8 +19,9 @@ impl JobDao { } futures::future::join_all(missing_thumbnails.into_iter().map(|f| async { + let file = f; file_dao - .create_thumbnails(f, vec![ThumbnailSize::Medium]) + .create_thumbnails(&file, vec![ThumbnailSize::Medium]) .await })) .await; diff --git a/mediarepo-daemon/mediarepo-socket/src/namespaces/files/mod.rs b/mediarepo-daemon/mediarepo-socket/src/namespaces/files/mod.rs index 68711d1..2c02703 100644 --- a/mediarepo-daemon/mediarepo-socket/src/namespaces/files/mod.rs +++ b/mediarepo-daemon/mediarepo-socket/src/namespaces/files/mod.rs @@ -231,7 +231,7 @@ impl FilesNamespace { let file = file_by_identifier(request.id, &repo).await?; thumbnails = repo .file() - .create_thumbnails(file, vec![ThumbnailSize::Medium]) + .create_thumbnails(&file, vec![ThumbnailSize::Medium]) .await?; tracing::debug!("Thumbnails for file created."); } @@ -271,7 +271,7 @@ impl FilesNamespace { let middle_size = ((max_size.0 + min_size.0) / 2, (max_size.1 + min_size.1) / 2); let thumbnail = repo .file() - .create_thumbnails(file, vec![ThumbnailSize::Custom(middle_size)]) + .create_thumbnails(&file, vec![ThumbnailSize::Custom(middle_size)]) .await?; thumbnail