mirror of
https://github.com/modrinth/code.git
synced 2026-08-26 09:34:50 +00:00
41 lines
1.0 KiB
Rust
41 lines
1.0 KiB
Rust
use crate::validate::{
|
|
SupportedGameVersions, ValidationError, ValidationResult,
|
|
validate_pack_formats,
|
|
};
|
|
use chrono::DateTime;
|
|
use std::io::Cursor;
|
|
use zip::ZipArchive;
|
|
|
|
pub struct QuiltValidator;
|
|
|
|
impl super::Validator for QuiltValidator {
|
|
fn get_file_extensions(&self) -> &[&str] {
|
|
&["jar", "zip"]
|
|
}
|
|
|
|
fn get_supported_loaders(&self) -> &[&str] {
|
|
&["quilt"]
|
|
}
|
|
|
|
fn get_supported_game_versions(&self) -> SupportedGameVersions {
|
|
SupportedGameVersions::PastDate(
|
|
DateTime::from_timestamp_secs(1646070100).unwrap(),
|
|
)
|
|
}
|
|
|
|
fn validate(
|
|
&self,
|
|
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
|
|
) -> Result<ValidationResult, ValidationError> {
|
|
if archive.by_name("quilt.mod.json").is_err()
|
|
&& archive.by_name("fabric.mod.json").is_err()
|
|
{
|
|
return Ok(ValidationResult::Warning(
|
|
"No quilt.mod.json present for Quilt file.",
|
|
));
|
|
}
|
|
|
|
Ok(validate_pack_formats(archive))
|
|
}
|
|
}
|