Make already-claimed a 400

This commit is contained in:
asonix 2022-06-05 23:24:27 -05:00
parent 9cfc1ed733
commit dc73bdbad4
2 changed files with 6 additions and 2 deletions

View file

@ -81,6 +81,9 @@ pub(crate) enum UploadError {
#[error("No files present in upload")] #[error("No files present in upload")]
NoFiles, NoFiles,
#[error("Upload was already claimed")]
AlreadyClaimed,
#[error("Requested a file that doesn't exist")] #[error("Requested a file that doesn't exist")]
MissingAlias, MissingAlias,
@ -154,6 +157,7 @@ impl ResponseError for Error {
| UploadError::NoFiles | UploadError::NoFiles
| UploadError::Upload(_) | UploadError::Upload(_)
| UploadError::UnsupportedFormat | UploadError::UnsupportedFormat
| UploadError::AlreadyClaimed
| UploadError::SilentVideoDisabled, | UploadError::SilentVideoDisabled,
) => StatusCode::BAD_REQUEST, ) => StatusCode::BAD_REQUEST,
Some( Some(

View file

@ -298,13 +298,13 @@ impl UploadRepo for SledRepo {
return Ok(result.into()); return Ok(result.into());
} }
} else { } else {
return Err(UploadError::NoFiles.into()); return Err(UploadError::AlreadyClaimed.into());
} }
while let Some(event) = (&mut subscriber).await { while let Some(event) = (&mut subscriber).await {
match event { match event {
sled::Event::Remove { .. } => { sled::Event::Remove { .. } => {
return Err(UploadError::NoFiles.into()); return Err(UploadError::AlreadyClaimed.into());
} }
sled::Event::Insert { value, .. } => { sled::Event::Insert { value, .. } => {
if value != b"1" { if value != b"1" {