2023-04-20 16:38:30 -07:00
|
|
|
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
|
2022-07-31 13:29:20 -07:00
|
|
|
use chrono::{DateTime, NaiveDateTime, Utc};
|
2022-04-24 13:02:41 -07:00
|
|
|
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] {
|
2022-07-10 03:25:44 +00:00
|
|
|
&["quilt"]
|
2022-04-24 13:02:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_supported_game_versions(&self) -> SupportedGameVersions {
|
2023-10-11 15:55:01 -07:00
|
|
|
SupportedGameVersions::PastDate(DateTime::from_naive_utc_and_offset(
|
2023-02-22 16:11:14 -07:00
|
|
|
NaiveDateTime::from_timestamp_opt(1646070100, 0).unwrap(),
|
2022-07-31 13:29:20 -07:00
|
|
|
Utc,
|
2022-04-24 13:02:41 -07:00
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn validate(
|
|
|
|
|
&self,
|
|
|
|
|
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
|
|
|
|
|
) -> Result<ValidationResult, ValidationError> {
|
2023-04-16 20:03:53 -07:00
|
|
|
if archive.by_name("quilt.mod.json").is_err() {
|
|
|
|
|
return Ok(ValidationResult::Warning(
|
|
|
|
|
"No quilt.mod.json present for Quilt file.",
|
|
|
|
|
));
|
|
|
|
|
}
|
2022-04-24 13:02:41 -07:00
|
|
|
|
|
|
|
|
Ok(ValidationResult::Pass)
|
|
|
|
|
}
|
|
|
|
|
}
|