fix: don't allow empty drawings to be uploaded
This commit is contained in:
parent
16843a6ab8
commit
a4298f95f6
2 changed files with 5 additions and 0 deletions
|
@ -415,6 +415,9 @@ impl DataManager {
|
||||||
// this is the initial iter to check sizes, we'll do uploads after
|
// this is the initial iter to check sizes, we'll do uploads after
|
||||||
if drawing.len() > Self::MAXIMUM_DRAWING_SIZE {
|
if drawing.len() > Self::MAXIMUM_DRAWING_SIZE {
|
||||||
return Err(Error::FileTooLarge);
|
return Err(Error::FileTooLarge);
|
||||||
|
} else if drawing.len() < 25 {
|
||||||
|
// if we have less than 25 bytes in a drawing, the drawing is likely blank
|
||||||
|
return Err(Error::FileTooSmall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ pub enum Error {
|
||||||
DataTooLong(String),
|
DataTooLong(String),
|
||||||
DataTooShort(String),
|
DataTooShort(String),
|
||||||
FileTooLarge,
|
FileTooLarge,
|
||||||
|
FileTooSmall,
|
||||||
UsernameInUse,
|
UsernameInUse,
|
||||||
TitleInUse,
|
TitleInUse,
|
||||||
QuestionsDisabled,
|
QuestionsDisabled,
|
||||||
|
@ -66,6 +67,7 @@ impl Display for Error {
|
||||||
Self::DataTooLong(name) => format!("Given {name} is too long!"),
|
Self::DataTooLong(name) => format!("Given {name} is too long!"),
|
||||||
Self::DataTooShort(name) => format!("Given {name} is too short!"),
|
Self::DataTooShort(name) => format!("Given {name} is too short!"),
|
||||||
Self::FileTooLarge => "Given file is too large".to_string(),
|
Self::FileTooLarge => "Given file is too large".to_string(),
|
||||||
|
Self::FileTooSmall => "Given file is too small".to_string(),
|
||||||
Self::UsernameInUse => "Username in use".to_string(),
|
Self::UsernameInUse => "Username in use".to_string(),
|
||||||
Self::TitleInUse => "Title in use".to_string(),
|
Self::TitleInUse => "Title in use".to_string(),
|
||||||
Self::QuestionsDisabled => "You are not allowed to ask questions there".to_string(),
|
Self::QuestionsDisabled => "You are not allowed to ask questions there".to_string(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue