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 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)
}
}

@ -58,7 +58,7 @@ impl FileDao {
#[tracing::instrument(level = "debug", skip(self))]
pub async fn create_thumbnails<I: IntoIterator<Item = ThumbnailSize> + Debug>(
&self,
file: FileDto,
file: &FileDto,
sizes: I,
) -> RepoResult<Vec<ThumbnailDto>> {
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 {
let file = f;
file_dao
.create_thumbnails(f, vec![ThumbnailSize::Medium])
.create_thumbnails(&file, vec![ThumbnailSize::Medium])
.await
}))
.await;

@ -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

Loading…
Cancel
Save