refactor: refactor is_portfolio_prepared

This commit is contained in:
EETagent 2022-11-16 16:26:42 +01:00
parent 530994f33d
commit e9f3a8042c

View file

@ -127,15 +127,15 @@ impl CandidateService {
pub async fn is_portfolio_prepared(candidate_id: i32) -> bool { pub async fn is_portfolio_prepared(candidate_id: i32) -> bool {
let cache_path = Path::new(&candidate_id.to_string()).join("cache"); let cache_path = Path::new(&candidate_id.to_string()).join("cache");
tokio::fs::metadata(cache_path.join("MOTIVACNI_DOPIS.pdf")) let filenames = vec!["MOTIVACNI_DOPIS.pdf", "PORTFOLIO.pdf", "PORTFOLIO.zip"];
.await
.is_ok() for filename in filenames {
&& tokio::fs::metadata(cache_path.join("PORTFOLIO.pdf")) if !tokio::fs::metadata(cache_path.join(filename)).await.is_ok() {
.await return false;
.is_ok() }
&& tokio::fs::metadata(cache_path.join("PORTFOLIO.zip")) }
.await
.is_ok() true
} }
pub async fn delete_cache(candidate_id: i32) -> Result<(), ServiceError> { pub async fn delete_cache(candidate_id: i32) -> Result<(), ServiceError> {