From dc73bdbad42b55e7b9a0279920bfb734b81b8aa8 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 5 Jun 2022 23:24:27 -0500 Subject: [PATCH] Make already-claimed a 400 --- src/error.rs | 4 ++++ src/repo/sled.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/error.rs b/src/error.rs index db99cb4..fe1bfd2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -81,6 +81,9 @@ pub(crate) enum UploadError { #[error("No files present in upload")] NoFiles, + #[error("Upload was already claimed")] + AlreadyClaimed, + #[error("Requested a file that doesn't exist")] MissingAlias, @@ -154,6 +157,7 @@ impl ResponseError for Error { | UploadError::NoFiles | UploadError::Upload(_) | UploadError::UnsupportedFormat + | UploadError::AlreadyClaimed | UploadError::SilentVideoDisabled, ) => StatusCode::BAD_REQUEST, Some( diff --git a/src/repo/sled.rs b/src/repo/sled.rs index 5eed976..75a9171 100644 --- a/src/repo/sled.rs +++ b/src/repo/sled.rs @@ -298,13 +298,13 @@ impl UploadRepo for SledRepo { return Ok(result.into()); } } else { - return Err(UploadError::NoFiles.into()); + return Err(UploadError::AlreadyClaimed.into()); } while let Some(event) = (&mut subscriber).await { match event { sled::Event::Remove { .. } => { - return Err(UploadError::NoFiles.into()); + return Err(UploadError::AlreadyClaimed.into()); } sled::Event::Insert { value, .. } => { if value != b"1" {