mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-16 21:11:06 +00:00
feat: safer portfolio submit
This commit is contained in:
parent
efa4fbe40d
commit
96a93dad3a
3 changed files with 8 additions and 1 deletions
|
|
@ -213,7 +213,6 @@ pub async fn submit_portfolio(
|
|||
if submit.is_err() {
|
||||
let e = submit.err().unwrap();
|
||||
// Delete on critical error
|
||||
// TODO: Více kontrol?
|
||||
if e.code() == 500 {
|
||||
// Cleanup
|
||||
PortfolioService::delete_portfolio(candidate.application)
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ pub enum ServiceError {
|
|||
AesError(#[from] aes_gcm_siv::Error),
|
||||
#[error("Portfolio is incomplete")]
|
||||
IncompletePortfolio,
|
||||
#[error("Portfolio write error")]
|
||||
PortfolioWriteError,
|
||||
#[error("Zip error")]
|
||||
ZipError(#[from] async_zip::error::ZipError),
|
||||
#[error("Csv error")]
|
||||
|
|
@ -95,6 +97,7 @@ impl ServiceError {
|
|||
ServiceError::TokioJoinError(_) => 500,
|
||||
ServiceError::AesError(_) => 500,
|
||||
ServiceError::ArgonConfigError(_) => 500,
|
||||
ServiceError::PortfolioWriteError => 500,
|
||||
ServiceError::ZipError(_) => 500,
|
||||
ServiceError::CsvError(_) => 500,
|
||||
ServiceError::CsvIntoInnerError => 500,
|
||||
|
|
|
|||
|
|
@ -314,6 +314,11 @@ impl PortfolioService {
|
|||
).await?;
|
||||
tokio::fs::remove_file(final_path).await?;
|
||||
|
||||
|
||||
if !Self::is_portfolio_submitted(candidate_id).await {
|
||||
return Err(ServiceError::PortfolioWriteError)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue