1
0

Add dependencies to search (#578)

* Add dependencies to search

* add attrs for faceting

* run prepare

* Add user data route from token

* update to 24hrs

* Fix report bugs
This commit is contained in:
Geometrically
2023-04-20 16:38:30 -07:00
committed by GitHub
parent 5c559af936
commit 59f24df294
65 changed files with 1518 additions and 2218 deletions

View File

@@ -1,6 +1,4 @@
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use std::io::Cursor;
use zip::ZipArchive;

View File

@@ -1,6 +1,4 @@
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use chrono::{DateTime, NaiveDateTime, Utc};
use std::io::Cursor;
use zip::ZipArchive;
@@ -38,9 +36,10 @@ impl super::Validator for FabricValidator {
));
}
if !archive.file_names().any(|name| {
name.ends_with("refmap.json") || name.ends_with(".class")
}) {
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!",
));

View File

@@ -1,6 +1,4 @@
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use chrono::{DateTime, NaiveDateTime, Utc};
use std::io::Cursor;
use zip::ZipArchive;

View File

@@ -1,6 +1,4 @@
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use std::io::Cursor;
use zip::ZipArchive;

View File

@@ -8,9 +8,7 @@ use crate::validate::modpack::ModpackValidator;
use crate::validate::plugin::*;
use crate::validate::quilt::QuiltValidator;
use crate::validate::resourcepack::{PackValidator, TexturePackValidator};
use crate::validate::shader::{
CanvasShaderValidator, CoreShaderValidator, ShaderValidator,
};
use crate::validate::shader::{CanvasShaderValidator, CoreShaderValidator, ShaderValidator};
use chrono::{DateTime, Utc};
use std::io::Cursor;
use thiserror::Error;
@@ -119,8 +117,7 @@ pub async fn validate_file(
if let Some(file_type) = file_type {
match file_type {
FileType::RequiredResourcePack
| FileType::OptionalResourcePack => {
FileType::RequiredResourcePack | FileType::OptionalResourcePack => {
project_type = "resourcepack".to_string();
loaders = vec![Loader("minecraft".to_string())];
}
@@ -150,13 +147,12 @@ pub async fn validate_file(
if visited {
if ALWAYS_ALLOWED_EXT.contains(&&*file_extension) {
Ok(ValidationResult::Warning("File extension is invalid for input file"))
Ok(ValidationResult::Warning(
"File extension is invalid for input file",
))
} else {
Err(ValidationError::InvalidInput(
format!(
"File extension {file_extension} is invalid for input file"
)
.into(),
format!("File extension {file_extension} is invalid for input file").into(),
))
}
} else {
@@ -173,24 +169,20 @@ fn game_version_supported(
) -> bool {
match supported_game_versions {
SupportedGameVersions::All => true,
SupportedGameVersions::PastDate(date) => {
game_versions.iter().any(|x| {
all_game_versions
.iter()
.find(|y| y.version == x.0)
.map(|x| x.created > date)
.unwrap_or(false)
})
}
SupportedGameVersions::Range(before, after) => {
game_versions.iter().any(|x| {
all_game_versions
.iter()
.find(|y| y.version == x.0)
.map(|x| x.created > before && x.created < after)
.unwrap_or(false)
})
}
SupportedGameVersions::PastDate(date) => game_versions.iter().any(|x| {
all_game_versions
.iter()
.find(|y| y.version == x.0)
.map(|x| x.created > date)
.unwrap_or(false)
}),
SupportedGameVersions::Range(before, after) => game_versions.iter().any(|x| {
all_game_versions
.iter()
.find(|y| y.version == x.0)
.map(|x| x.created > before && x.created < after)
.unwrap_or(false)
}),
SupportedGameVersions::Custom(versions) => {
versions.iter().any(|x| game_versions.contains(x))
}

View File

@@ -1,8 +1,6 @@
use crate::models::pack::{PackFileHash, PackFormat};
use crate::util::validate::validation_errors_to_string;
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use std::io::{Cursor, Read};
use std::path::Component;
use validator::Validate;
@@ -32,14 +30,11 @@ impl super::Validator for ModpackValidator {
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
) -> Result<ValidationResult, ValidationError> {
let pack: PackFormat = {
let mut file =
if let Ok(file) = archive.by_name("modrinth.index.json") {
file
} else {
return Ok(ValidationResult::Warning(
"Pack manifest is missing.",
));
};
let mut file = if let Ok(file) = archive.by_name("modrinth.index.json") {
file
} else {
return Ok(ValidationResult::Warning("Pack manifest is missing."));
};
let mut contents = String::new();
file.read_to_string(&mut contents)?;
@@ -48,9 +43,7 @@ impl super::Validator for ModpackValidator {
};
pack.validate().map_err(|err| {
ValidationError::InvalidInput(
validation_errors_to_string(err, None).into(),
)
ValidationError::InvalidInput(validation_errors_to_string(err, None).into())
})?;
if pack.game != "minecraft" {
@@ -75,11 +68,7 @@ impl super::Validator for ModpackValidator {
let path = std::path::Path::new(&file.path)
.components()
.next()
.ok_or_else(|| {
ValidationError::InvalidInput(
"Invalid pack file path!".into(),
)
})?;
.ok_or_else(|| ValidationError::InvalidInput("Invalid pack file path!".into()))?;
match path {
Component::CurDir | Component::Normal(_) => {}

View File

@@ -1,6 +1,4 @@
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use std::io::Cursor;
use zip::ZipArchive;

View File

@@ -1,6 +1,4 @@
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use chrono::{DateTime, NaiveDateTime, Utc};
use std::io::Cursor;
use zip::ZipArchive;
@@ -37,9 +35,10 @@ impl super::Validator for QuiltValidator {
));
}
if !archive.file_names().any(|name| {
name.ends_with("refmap.json") || name.ends_with(".class")
}) {
if !archive
.file_names()
.any(|name| name.ends_with("refmap.json") || name.ends_with(".class"))
{
return Ok(ValidationResult::Warning(
"Quilt mod file is a source file!",
));

View File

@@ -1,6 +1,4 @@
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use chrono::{DateTime, NaiveDateTime, Utc};
use std::io::Cursor;
use zip::ZipArchive;

View File

@@ -1,6 +1,4 @@
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use std::io::Cursor;
use zip::ZipArchive;