Clarify some constants
This commit is contained in:
@ -24,7 +24,7 @@ pub async fn upload(MultipartForm(mut form): MultipartForm<UploadDiskImageForm>)
|
||||
let file = form.files.remove(0);
|
||||
|
||||
// Check uploaded file size
|
||||
if file.size > constants::DISK_IMAGE_MAX_SIZE {
|
||||
if file.size > constants::DISK_IMAGE_MAX_SIZE.as_bytes() {
|
||||
return Ok(HttpResponse::BadRequest().json("Disk image max size exceeded!"));
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ pub async fn upload_file(MultipartForm(mut form): MultipartForm<UploadIsoForm>)
|
||||
|
||||
let file = form.files.remove(0);
|
||||
|
||||
if file.size > constants::ISO_MAX_SIZE {
|
||||
if file.size > constants::ISO_MAX_SIZE.as_bytes() {
|
||||
log::error!("Uploaded ISO file is too large!");
|
||||
return Ok(HttpResponse::BadRequest().json("File is too large!"));
|
||||
}
|
||||
@ -88,7 +88,7 @@ pub async fn upload_from_url(req: web::Json<DownloadFromURLReq>) -> HttpResult {
|
||||
let response = reqwest::get(&req.url).await?;
|
||||
|
||||
if let Some(len) = response.content_length() {
|
||||
if len > constants::ISO_MAX_SIZE as u64 {
|
||||
if len > constants::ISO_MAX_SIZE.as_bytes() as u64 {
|
||||
return Ok(HttpResponse::BadRequest().json("File is too large!"));
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ pub async fn static_config(local_auth: LocalAuthEnabled) -> impl Responder {
|
||||
builtin_nwfilter_rules: &constants::BUILTIN_NETWORK_FILTER_RULES,
|
||||
nwfilter_chains: &constants::NETWORK_CHAINS,
|
||||
constraints: ServerConstraints {
|
||||
iso_max_size: constants::ISO_MAX_SIZE,
|
||||
disk_image_max_size: constants::DISK_IMAGE_MAX_SIZE,
|
||||
iso_max_size: constants::ISO_MAX_SIZE.as_bytes(),
|
||||
disk_image_max_size: constants::DISK_IMAGE_MAX_SIZE.as_bytes(),
|
||||
|
||||
vnc_token_duration: VNC_TOKEN_LIFETIME,
|
||||
|
||||
|
Reference in New Issue
Block a user