Prevent empty archive extraction
This commit is contained in:
parent
c100d87145
commit
d85cce8264
@ -5,7 +5,7 @@ use actix_files::{Files, NamedFile};
|
||||
use actix_multipart::Multipart;
|
||||
use actix_web::{App, Error, HttpRequest, HttpResponse, HttpServer, web};
|
||||
use actix_web::dev::{fn_service, ServiceRequest, ServiceResponse};
|
||||
use actix_web::error::{ErrorInternalServerError, ErrorUnauthorized};
|
||||
use actix_web::error::{ErrorBadRequest, ErrorInternalServerError, ErrorUnauthorized};
|
||||
use actix_web::middleware::Logger;
|
||||
use bytes::BufMut;
|
||||
use clap::Parser;
|
||||
@ -178,6 +178,11 @@ async fn replace_files(args: web::Data<Args>, req: HttpRequest, mut payload: Mul
|
||||
}
|
||||
}
|
||||
|
||||
// Check if at least a file was sent
|
||||
if new_files.is_empty() {
|
||||
return Err(ErrorBadRequest("No file to extract!"));
|
||||
}
|
||||
|
||||
// Delete all current files in storage
|
||||
for entry in std::fs::read_dir(args.storage_path())? {
|
||||
let entry = entry?;
|
||||
|
Loading…
Reference in New Issue
Block a user