Fix thumbnails not being generated on import

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/14/head
trivernis 3 years ago
parent 6007d2a096
commit 7189f65afd
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -5,6 +5,7 @@ use sea_orm::ActiveValue::Set;
use sea_orm::{ActiveModelTrait, DatabaseTransaction, TransactionTrait}; use sea_orm::{ActiveModelTrait, DatabaseTransaction, TransactionTrait};
use mediarepo_core::error::RepoResult; use mediarepo_core::error::RepoResult;
use mediarepo_core::thumbnailer::ThumbnailSize;
use mediarepo_database::entities::{content_descriptor, file, file_metadata}; use mediarepo_database::entities::{content_descriptor, file, file_metadata};
use crate::dao::file::FileDao; use crate::dao::file::FileDao;
@ -44,8 +45,11 @@ impl FileDao {
.await?; .await?;
trx.commit().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)
} }
} }

@ -58,7 +58,7 @@ impl FileDao {
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn create_thumbnails<I: IntoIterator<Item = ThumbnailSize> + Debug>( pub async fn create_thumbnails<I: IntoIterator<Item = ThumbnailSize> + Debug>(
&self, &self,
file: FileDto, file: &FileDto,
sizes: I, sizes: I,
) -> RepoResult<Vec<ThumbnailDto>> { ) -> RepoResult<Vec<ThumbnailDto>> {
let bytes = self.get_bytes(file.cd()).await?; let bytes = self.get_bytes(file.cd()).await?;

@ -19,8 +19,9 @@ impl JobDao {
} }
futures::future::join_all(missing_thumbnails.into_iter().map(|f| async { futures::future::join_all(missing_thumbnails.into_iter().map(|f| async {
let file = f;
file_dao file_dao
.create_thumbnails(f, vec![ThumbnailSize::Medium]) .create_thumbnails(&file, vec![ThumbnailSize::Medium])
.await .await
})) }))
.await; .await;

@ -231,7 +231,7 @@ impl FilesNamespace {
let file = file_by_identifier(request.id, &repo).await?; let file = file_by_identifier(request.id, &repo).await?;
thumbnails = repo thumbnails = repo
.file() .file()
.create_thumbnails(file, vec![ThumbnailSize::Medium]) .create_thumbnails(&file, vec![ThumbnailSize::Medium])
.await?; .await?;
tracing::debug!("Thumbnails for file created."); 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 middle_size = ((max_size.0 + min_size.0) / 2, (max_size.1 + min_size.1) / 2);
let thumbnail = repo let thumbnail = repo
.file() .file()
.create_thumbnails(file, vec![ThumbnailSize::Custom(middle_size)]) .create_thumbnails(&file, vec![ThumbnailSize::Custom(middle_size)])
.await?; .await?;
thumbnail thumbnail

Loading…
Cancel
Save