You've already forked AstralRinth
forked from didirus/AstralRinth
Fix project creation hash lookups failing (#239)
This commit is contained in:
@@ -586,7 +586,6 @@ pub async fn upload_file(
|
|||||||
.ok_or_else(|| CreateError::InvalidFileType(file_extension.to_string()))?;
|
.ok_or_else(|| CreateError::InvalidFileType(file_extension.to_string()))?;
|
||||||
|
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
let mut hash = sha1::Sha1::new();
|
|
||||||
while let Some(chunk) = field.next().await {
|
while let Some(chunk) = field.next().await {
|
||||||
// Project file size limit of 100MiB
|
// Project file size limit of 100MiB
|
||||||
const FILE_SIZE_CAP: usize = 100 * (1 << 20);
|
const FILE_SIZE_CAP: usize = 100 * (1 << 20);
|
||||||
@@ -597,12 +596,11 @@ pub async fn upload_file(
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
let bytes = chunk.map_err(CreateError::MultipartError)?;
|
let bytes = chunk.map_err(CreateError::MultipartError)?;
|
||||||
hash.update(&data);
|
|
||||||
data.append(&mut bytes.to_vec());
|
data.append(&mut bytes.to_vec());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let hash = hash.digest().to_string();
|
let hash = sha1::Sha1::from(&data).hexdigest();
|
||||||
let exists = sqlx::query!(
|
let exists = sqlx::query!(
|
||||||
"
|
"
|
||||||
SELECT EXISTS(SELECT 1 FROM hashes h
|
SELECT EXISTS(SELECT 1 FROM hashes h
|
||||||
|
|||||||
@@ -220,7 +220,6 @@ pub struct EditVersion {
|
|||||||
#[validate(length(max = 65536))]
|
#[validate(length(max = 65536))]
|
||||||
pub changelog: Option<String>,
|
pub changelog: Option<String>,
|
||||||
pub version_type: Option<models::projects::VersionType>,
|
pub version_type: Option<models::projects::VersionType>,
|
||||||
#[validate(length(min = 1, max = 256))]
|
|
||||||
pub dependencies: Option<Vec<Dependency>>,
|
pub dependencies: Option<Vec<Dependency>>,
|
||||||
pub game_versions: Option<Vec<models::projects::GameVersion>>,
|
pub game_versions: Option<Vec<models::projects::GameVersion>>,
|
||||||
pub loaders: Option<Vec<models::projects::Loader>>,
|
pub loaders: Option<Vec<models::projects::Loader>>,
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ pub fn validate_file(
|
|||||||
|
|
||||||
let mut visited = false;
|
let mut visited = false;
|
||||||
for validator in &VALIDATORS {
|
for validator in &VALIDATORS {
|
||||||
if
|
if validator.get_project_types().contains(&project_type)
|
||||||
validator.get_project_types().contains(&project_type)
|
|
||||||
&& loaders
|
&& loaders
|
||||||
.iter()
|
.iter()
|
||||||
.any(|x| validator.get_supported_loaders().contains(&&*x.0))
|
.any(|x| validator.get_supported_loaders().contains(&&*x.0))
|
||||||
@@ -90,7 +89,10 @@ pub fn validate_file(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if visited {
|
if visited {
|
||||||
Err(ValidationError::InvalidInputError(format!("File extension {} is invalid for input file", file_extension)))
|
Err(ValidationError::InvalidInputError(format!(
|
||||||
|
"File extension {} is invalid for input file",
|
||||||
|
file_extension
|
||||||
|
)))
|
||||||
} else {
|
} else {
|
||||||
Ok(ValidationResult::Pass)
|
Ok(ValidationResult::Pass)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user