-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add job to generate missing thumbnails on startup
Signed-off-by: trivernis <trivernis@protonmail.com>
- Loading branch information
Showing
15 changed files
with
59 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "mediarepo-api" | ||
version = "0.29.0" | ||
version = "0.30.0" | ||
edition = "2018" | ||
license = "gpl-3" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
mediarepo-daemon/mediarepo-logic/src/dao/job/generate_missing_thumbnails.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::dao::job::JobDao; | ||
use crate::dao::DaoProvider; | ||
use mediarepo_core::error::RepoResult; | ||
use mediarepo_core::futures; | ||
use mediarepo_core::thumbnailer::ThumbnailSize; | ||
|
||
impl JobDao { | ||
/// Generates thumbnails for files that are still missing some | ||
#[tracing::instrument(level = "debug", skip(self))] | ||
pub async fn generate_missing_thumbnails(&self) -> RepoResult<()> { | ||
let file_dao = self.file(); | ||
let files = file_dao.all().await?; | ||
let mut missing_thumbnails = Vec::new(); | ||
|
||
for file in files { | ||
if file_dao.thumbnails(file.encoded_cd()).await?.is_empty() { | ||
missing_thumbnails.push(file); | ||
} | ||
} | ||
|
||
futures::future::join_all(missing_thumbnails.into_iter().map(|f| async { | ||
file_dao | ||
.create_thumbnails(f, vec![ThumbnailSize::Medium]) | ||
.await | ||
})) | ||
.await; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export type JobType = "MigrateContentDescriptors" | ||
| "CalculateSizes" | ||
| "CheckIntegrity" | ||
| "Vacuum"; | ||
| "Vacuum" | ||
| "GenerateThumbnails"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters