mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-14 12:01:25 +00:00
feat: use seperate functions
This commit is contained in:
parent
e360983d88
commit
b31b557ae0
2 changed files with 28 additions and 19 deletions
|
|
@ -128,12 +128,9 @@ pub async fn upload_cover_letter(
|
|||
pub async fn delete_cover_letter(session: CandidateAuth) -> Result<(), Custom<String>> {
|
||||
let candidate: entity::candidate::Model = session.into();
|
||||
|
||||
PortfolioService::delete_cache_item(
|
||||
candidate.application,
|
||||
portfolio_core::services::portfolio_service::FileType::CoverLetterPdf,
|
||||
)
|
||||
.await
|
||||
.map_err(to_custom_error)?;
|
||||
PortfolioService::delete_cover_letter_from_cache(candidate.application)
|
||||
.await
|
||||
.map_err(to_custom_error)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -156,12 +153,9 @@ pub async fn upload_portfolio_letter(
|
|||
pub async fn delete_portfolio_letter(session: CandidateAuth) -> Result<(), Custom<String>> {
|
||||
let candidate: entity::candidate::Model = session.into();
|
||||
|
||||
PortfolioService::delete_cache_item(
|
||||
candidate.application,
|
||||
portfolio_core::services::portfolio_service::FileType::PortfolioLetterPdf,
|
||||
)
|
||||
.await
|
||||
.map_err(to_custom_error)?;
|
||||
PortfolioService::delete_portfolio_letter_from_cache(candidate.application)
|
||||
.await
|
||||
.map_err(to_custom_error)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -184,12 +178,9 @@ pub async fn upload_portfolio_zip(
|
|||
pub async fn delete_portfolio_zip(session: CandidateAuth) -> Result<(), Custom<String>> {
|
||||
let candidate: entity::candidate::Model = session.into();
|
||||
|
||||
PortfolioService::delete_cache_item(
|
||||
candidate.application,
|
||||
portfolio_core::services::portfolio_service::FileType::PortfolioZip,
|
||||
)
|
||||
.await
|
||||
.map_err(to_custom_error)?;
|
||||
PortfolioService::delete_portfolio_zip_from_cache(candidate.application)
|
||||
.await
|
||||
.map_err(to_custom_error)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ impl PortfolioService {
|
|||
|
||||
|
||||
/// Returns true if portfolio is ready to be moved to the final directory
|
||||
pub async fn is_portfolio_prepared(candidate_id: i32) -> bool {
|
||||
async fn is_portfolio_prepared(candidate_id: i32) -> bool {
|
||||
let cache_path = Self::get_file_store_path().join(&candidate_id.to_string()).join("cache");
|
||||
|
||||
let filenames = vec![FileType::CoverLetterPdf, FileType::PortfolioLetterPdf, FileType::PortfolioZip];
|
||||
|
|
@ -233,6 +233,24 @@ impl PortfolioService {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_cover_letter_from_cache(
|
||||
candidate_id: i32,
|
||||
) -> Result<(), ServiceError> {
|
||||
Self::delete_cache_item(candidate_id, FileType::CoverLetterPdf).await
|
||||
}
|
||||
|
||||
pub async fn delete_portfolio_letter_from_cache(
|
||||
candidate_id: i32,
|
||||
) -> Result<(), ServiceError> {
|
||||
Self::delete_cache_item(candidate_id, FileType::PortfolioLetterPdf).await
|
||||
}
|
||||
|
||||
pub async fn delete_portfolio_zip_from_cache(
|
||||
candidate_id: i32,
|
||||
) -> Result<(), ServiceError> {
|
||||
Self::delete_cache_item(candidate_id, FileType::PortfolioZip).await
|
||||
}
|
||||
|
||||
/// Removes all files from cache
|
||||
pub async fn delete_cache(candidate_id: i32) -> Result<(), ServiceError> {
|
||||
let cache_path = Self::get_file_store_path().join(&candidate_id.to_string()).join("cache");
|
||||
|
|
|
|||
Loading…
Reference in a new issue