You've already forked AstralRinth
forked from didirus/AstralRinth
Add deps list for override mods, fix version editing for packs (#363)
This commit is contained in:
@@ -33,7 +33,10 @@ pub enum ValidationError {
|
||||
#[derive(Eq, PartialEq)]
|
||||
pub enum ValidationResult {
|
||||
/// File should be marked as primary with pack file data
|
||||
PassWithPackData(PackFormat),
|
||||
PassWithPackDataAndFiles {
|
||||
format: PackFormat,
|
||||
files: Vec<String>,
|
||||
},
|
||||
/// File should be marked as primary
|
||||
Pass,
|
||||
/// File should not be marked primary, the reason for which is inside the String
|
||||
@@ -43,7 +46,7 @@ pub enum ValidationResult {
|
||||
impl ValidationResult {
|
||||
pub fn is_passed(&self) -> bool {
|
||||
match self {
|
||||
ValidationResult::PassWithPackData(_) => true,
|
||||
ValidationResult::PassWithPackDataAndFiles { .. } => true,
|
||||
ValidationResult::Pass => true,
|
||||
ValidationResult::Warning(_) => false,
|
||||
}
|
||||
|
||||
@@ -31,17 +31,19 @@ impl super::Validator for PackValidator {
|
||||
&self,
|
||||
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
|
||||
) -> Result<ValidationResult, ValidationError> {
|
||||
let mut file =
|
||||
archive.by_name("modrinth.index.json").map_err(|_| {
|
||||
ValidationError::InvalidInput(
|
||||
"Pack manifest is missing.".into(),
|
||||
)
|
||||
})?;
|
||||
let pack: PackFormat = {
|
||||
let mut file =
|
||||
archive.by_name("modrinth.index.json").map_err(|_| {
|
||||
ValidationError::InvalidInput(
|
||||
"Pack manifest is missing.".into(),
|
||||
)
|
||||
})?;
|
||||
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents)?;
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents)?;
|
||||
|
||||
let pack: PackFormat = serde_json::from_str(&contents)?;
|
||||
serde_json::from_str(&contents)?
|
||||
};
|
||||
|
||||
pack.validate().map_err(|err| {
|
||||
ValidationError::InvalidInput(
|
||||
@@ -87,6 +89,17 @@ impl super::Validator for PackValidator {
|
||||
};
|
||||
}
|
||||
|
||||
Ok(ValidationResult::PassWithPackData(pack))
|
||||
Ok(ValidationResult::PassWithPackDataAndFiles {
|
||||
format: pack,
|
||||
files: archive
|
||||
.file_names()
|
||||
.filter(|x| {
|
||||
x.starts_with("overrides/mods")
|
||||
|| x.starts_with("client-overrides/mods")
|
||||
|| x.starts_with("server-overrides/mods")
|
||||
})
|
||||
.flat_map(|x| x.rsplit('/').next().map(|x| x.to_string()))
|
||||
.collect::<Vec<String>>(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user