aboutsummaryrefslogtreecommitdiffstats
path: root/src/errors.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2025-03-03 03:54:51 +0000
committerGitHub <noreply@github.com>2025-03-03 03:54:51 +0000
commitc26b74c8a9f47f86b39a687b20d769e3b349fd8d (patch)
tree1c562da6fbcba9900ce85e300cc9298a0ddf23c8 /src/errors.rs
parentMerge pull request #1478 from svenstaro/dependabot/cargo/all-dependencies-65d... (diff)
parentfeat: validate temp dir exists through `value_parser` and fixed clippy issues (diff)
downloadminiserve-c26b74c8a9f47f86b39a687b20d769e3b349fd8d.tar.gz
miniserve-c26b74c8a9f47f86b39a687b20d769e3b349fd8d.zip
Merge pull request #1431 from AlecDivito/upload-progress-bar
feat: Added HTML and Javascript progress bar when uploading files
Diffstat (limited to '')
-rw-r--r--src/errors.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs
index 99c15ff..b7d75f2 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -43,6 +43,10 @@ pub enum RuntimeError {
#[error("File already exists, and the overwrite_files option has not been set")]
DuplicateFileError,
+ /// Uploaded hash not correct
+ #[error("File hash that was provided did not match checksum of uploaded file")]
+ UploadHashMismatchError,
+
/// Upload not allowed
#[error("Upload not allowed to this directory")]
UploadForbiddenError,
@@ -86,6 +90,7 @@ impl ResponseError for RuntimeError {
use StatusCode as S;
match self {
E::IoError(_, _) => S::INTERNAL_SERVER_ERROR,
+ E::UploadHashMismatchError => S::BAD_REQUEST,
E::MultipartError(_) => S::BAD_REQUEST,
E::DuplicateFileError => S::CONFLICT,
E::UploadForbiddenError => S::FORBIDDEN,
@@ -132,6 +137,7 @@ where
let res = fut.await?.map_into_boxed_body();
if (res.status().is_client_error() || res.status().is_server_error())
+ && res.request().path() != "/upload"
&& res
.headers()
.get(header::CONTENT_TYPE)