You've already forked AstralRinth
forked from didirus/AstralRinth
Shulkers of fixes (#327)
* Shulkers of fixes * Fix validation message * Update deps * Bump docker image version
This commit is contained in:
@@ -33,7 +33,7 @@ impl super::Validator for FabricValidator {
|
||||
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
|
||||
) -> Result<ValidationResult, ValidationError> {
|
||||
archive.by_name("fabric.mod.json").map_err(|_| {
|
||||
ValidationError::InvalidInputError(
|
||||
ValidationError::InvalidInput(
|
||||
"No fabric.mod.json present for Fabric file.".into(),
|
||||
)
|
||||
})?;
|
||||
|
||||
@@ -33,7 +33,7 @@ impl super::Validator for ForgeValidator {
|
||||
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
|
||||
) -> Result<ValidationResult, ValidationError> {
|
||||
archive.by_name("META-INF/mods.toml").map_err(|_| {
|
||||
ValidationError::InvalidInputError(
|
||||
ValidationError::InvalidInput(
|
||||
"No mods.toml present for Forge file.".into(),
|
||||
)
|
||||
})?;
|
||||
|
||||
@@ -14,15 +14,15 @@ mod pack;
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ValidationError {
|
||||
#[error("Unable to read Zip Archive: {0}")]
|
||||
ZipError(#[from] zip::result::ZipError),
|
||||
Zip(#[from] zip::result::ZipError),
|
||||
#[error("IO Error: {0}")]
|
||||
IoError(#[from] std::io::Error),
|
||||
Io(#[from] std::io::Error),
|
||||
#[error("Error while validating JSON: {0}")]
|
||||
SerdeError(#[from] serde_json::Error),
|
||||
SerDe(#[from] serde_json::Error),
|
||||
#[error("Invalid Input: {0}")]
|
||||
InvalidInputError(std::borrow::Cow<'static, str>),
|
||||
InvalidInput(std::borrow::Cow<'static, str>),
|
||||
#[error("Error while managing threads")]
|
||||
BlockingError(#[from] actix_web::error::BlockingError),
|
||||
Blocking(#[from] actix_web::error::BlockingError),
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
@@ -93,7 +93,7 @@ pub async fn validate_file(
|
||||
}
|
||||
|
||||
if visited {
|
||||
Err(ValidationError::InvalidInputError(
|
||||
Err(ValidationError::InvalidInput(
|
||||
format!(
|
||||
"File extension {} is invalid for input file",
|
||||
file_extension
|
||||
|
||||
@@ -138,7 +138,7 @@ impl super::Validator for PackValidator {
|
||||
) -> Result<ValidationResult, ValidationError> {
|
||||
let mut file =
|
||||
archive.by_name("modrinth.index.json").map_err(|_| {
|
||||
ValidationError::InvalidInputError(
|
||||
ValidationError::InvalidInput(
|
||||
"Pack manifest is missing.".into(),
|
||||
)
|
||||
})?;
|
||||
@@ -149,20 +149,20 @@ impl super::Validator for PackValidator {
|
||||
let pack: PackFormat = serde_json::from_str(&contents)?;
|
||||
|
||||
pack.validate().map_err(|err| {
|
||||
ValidationError::InvalidInputError(
|
||||
ValidationError::InvalidInput(
|
||||
validation_errors_to_string(err, None).into(),
|
||||
)
|
||||
})?;
|
||||
|
||||
if pack.game != "minecraft" {
|
||||
return Err(ValidationError::InvalidInputError(
|
||||
return Err(ValidationError::InvalidInput(
|
||||
format!("Game {0} does not exist!", pack.game).into(),
|
||||
));
|
||||
}
|
||||
|
||||
for file in pack.files {
|
||||
if file.hashes.get(&FileHash::Sha1).is_none() {
|
||||
return Err(ValidationError::InvalidInputError(
|
||||
return Err(ValidationError::InvalidInput(
|
||||
"All pack files must provide a SHA1 hash!".into(),
|
||||
));
|
||||
}
|
||||
@@ -171,7 +171,7 @@ impl super::Validator for PackValidator {
|
||||
.components()
|
||||
.next()
|
||||
.ok_or_else(|| {
|
||||
ValidationError::InvalidInputError(
|
||||
ValidationError::InvalidInput(
|
||||
"Invalid pack file path!".into(),
|
||||
)
|
||||
})?;
|
||||
@@ -179,7 +179,7 @@ impl super::Validator for PackValidator {
|
||||
match path {
|
||||
Component::CurDir | Component::Normal(_) => {}
|
||||
_ => {
|
||||
return Err(ValidationError::InvalidInputError(
|
||||
return Err(ValidationError::InvalidInput(
|
||||
"Invalid pack file path!".into(),
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user