Upgrade to Actix V2, bump SQLX version, code cleanup, intergrate ratelimiter (#288)

* Upgrade to Actix V2, bump SQLX version, code cleanup, intergrate ratelimiter

* Add pack file path validation

* Fix compilation error caused by incorrect merge
This commit is contained in:
Geometrically
2022-02-05 23:08:30 -07:00
committed by GitHub
parent 6a89646e66
commit 6bf5dbabee
27 changed files with 1417 additions and 1649 deletions

View File

@@ -22,7 +22,7 @@ pub enum ValidationError {
#[error("Invalid Input: {0}")]
InvalidInputError(std::borrow::Cow<'static, str>),
#[error("Error while managing threads")]
BlockingError,
BlockingError(#[from] actix_web::error::BlockingError),
}
#[derive(Eq, PartialEq)]
@@ -67,7 +67,7 @@ pub async fn validate_file(
game_versions: Vec<GameVersion>,
all_game_versions: Vec<crate::database::models::categories::GameVersion>,
) -> Result<ValidationResult, ValidationError> {
let res = actix_web::web::block(move || {
actix_web::web::block(move || {
let reader = std::io::Cursor::new(data);
let mut zip = zip::ZipArchive::new(reader)?;
@@ -103,15 +103,7 @@ pub async fn validate_file(
Ok(ValidationResult::Pass)
}
})
.await;
match res {
Ok(x) => Ok(x),
Err(err) => match err {
actix_web::error::BlockingError::Canceled => Err(ValidationError::BlockingError),
actix_web::error::BlockingError::Error(err) => Err(err),
},
}
.await?
}
fn game_version_supported(