You've already forked AstralRinth
forked from didirus/AstralRinth
Project Types, Code Cleanup, and Rename Mods -> Projects (#192)
* Initial work for modpacks and project types * Code cleanup, fix some issues * Username route getting, remove pointless tests * Base validator types + fixes * Fix strange IML generation * Multiple hash requests for version files * Fix docker build (hopefully) * Legacy routes * Finish validator architecture * Update rust version in dockerfile * Added caching and fixed typo (#203) * Added caching and fixed typo * Fixed clippy error * Removed log for cache * Add final validators, fix how loaders are handled and add icons to tags * Fix search module * Fix parts of legacy API not working Co-authored-by: Redblueflame <contact@redblueflame.com>
This commit is contained in:
48
src/validate/fabric.rs
Normal file
48
src/validate/fabric.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use std::io::Cursor;
|
||||
use zip::ZipArchive;
|
||||
|
||||
pub struct FabricValidator {}
|
||||
|
||||
impl super::Validator for FabricValidator {
|
||||
fn get_file_extensions<'a>(&self) -> &'a [&'a str] {
|
||||
&["jar", "zip"]
|
||||
}
|
||||
|
||||
fn get_project_types<'a>(&self) -> &'a [&'a str] {
|
||||
&["mod"]
|
||||
}
|
||||
|
||||
fn get_supported_loaders<'a>(&self) -> &'a [&'a str] {
|
||||
&["fabric"]
|
||||
}
|
||||
|
||||
fn get_supported_game_versions(&self) -> SupportedGameVersions {
|
||||
// Time since release of 18w49a, the first fabric version
|
||||
SupportedGameVersions::PastDate(DateTime::<Utc>::from_utc(
|
||||
NaiveDateTime::from_timestamp(1543969469, 0),
|
||||
Utc,
|
||||
))
|
||||
}
|
||||
|
||||
fn validate(
|
||||
&self,
|
||||
archive: &mut ZipArchive<Cursor<&[u8]>>,
|
||||
) -> Result<ValidationResult, ValidationError> {
|
||||
archive.by_name("fabric.mod.json")?;
|
||||
|
||||
if !archive
|
||||
.file_names()
|
||||
.any(|name| name.ends_with("refmap.json") || name.ends_with(".class"))
|
||||
{
|
||||
return Ok(ValidationResult::Warning(
|
||||
"Fabric mod file is a source file!".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
//TODO: Check if file is a dev JAR?
|
||||
|
||||
Ok(ValidationResult::Pass)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user