diff options
Diffstat (limited to 'src/listing.rs')
-rw-r--r-- | src/listing.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/listing.rs b/src/listing.rs index d419775..8ee6ead 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -1,4 +1,5 @@ use actix_web::{fs, Body, FromRequest, HttpRequest, HttpResponse, Query, Result}; +use actix_web::http::StatusCode; use bytesize::ByteSize; use futures::Stream; use htmlescape::encode_minimal as escape_html_entity; @@ -135,6 +136,7 @@ pub fn directory_listing<S>( random_route: Option<String>, default_color_scheme: ColorScheme, upload_route: String, + archives_enabled: bool, ) -> Result<HttpResponse, io::Error> { let serve_path = req.path(); @@ -249,6 +251,24 @@ pub fn directory_listing<S>( let color_scheme = query_params.theme.unwrap_or(default_color_scheme); if let Some(compression_method) = query_params.download { + if !archives_enabled { + return Ok(HttpResponse::Forbidden() + .content_type("text/html; charset=utf-8") + .body( + renderer::render_error( + "Archive creation is disabled.", + StatusCode::FORBIDDEN, + "/", + None, + None, + color_scheme, + default_color_scheme, + false, + false, + ).into_string() + ) + ); + } log::info!( "Creating an archive ({extension}) of {path}...", extension = compression_method.extension(), @@ -313,6 +333,7 @@ pub fn directory_listing<S>( file_upload, &upload_route, ¤t_dir.display().to_string(), + archives_enabled, ) .into_string(), )) |