From e9f3a8042c31f522dd5aa96f3f0df94a914f5542 Mon Sep 17 00:00:00 2001 From: EETagent Date: Wed, 16 Nov 2022 16:26:42 +0100 Subject: [PATCH] refactor: refactor is_portfolio_prepared --- core/src/services/candidate_service.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/services/candidate_service.rs b/core/src/services/candidate_service.rs index b44509d..affd052 100644 --- a/core/src/services/candidate_service.rs +++ b/core/src/services/candidate_service.rs @@ -127,15 +127,15 @@ impl CandidateService { pub async fn is_portfolio_prepared(candidate_id: i32) -> bool { let cache_path = Path::new(&candidate_id.to_string()).join("cache"); - tokio::fs::metadata(cache_path.join("MOTIVACNI_DOPIS.pdf")) - .await - .is_ok() - && tokio::fs::metadata(cache_path.join("PORTFOLIO.pdf")) - .await - .is_ok() - && tokio::fs::metadata(cache_path.join("PORTFOLIO.zip")) - .await - .is_ok() + let filenames = vec!["MOTIVACNI_DOPIS.pdf", "PORTFOLIO.pdf", "PORTFOLIO.zip"]; + + for filename in filenames { + if !tokio::fs::metadata(cache_path.join(filename)).await.is_ok() { + return false; + } + } + + true } pub async fn delete_cache(candidate_id: i32) -> Result<(), ServiceError> {