cargo clippy and fmt

This commit is contained in:
xenofem 2022-04-28 05:18:35 -04:00
parent 127d7e9c67
commit bda6da33e8
6 changed files with 129 additions and 68 deletions

View file

@ -5,14 +5,11 @@ mod upload;
mod util;
mod zip;
use std::{
path::PathBuf,
fs::File,
};
use std::{fs::File, path::PathBuf};
use actix::Addr;
use actix_web::{
get, middleware::Logger, web, App, HttpRequest, HttpServer, Responder, HttpResponse,
get, middleware::Logger, web, App, HttpRequest, HttpResponse, HttpServer, Responder,
};
use actix_web_actors::ws;
use serde::{Deserialize, Serialize};
@ -20,7 +17,7 @@ use state::PersistentState;
use time::OffsetDateTime;
use tokio::sync::RwLock;
const APP_NAME: &'static str = "transbeam";
const APP_NAME: &str = "transbeam";
pub struct UploadedFile {
name: String,
@ -55,7 +52,11 @@ fn storage_dir() -> PathBuf {
}
#[get("/download/{file_code}")]
async fn handle_download(req: HttpRequest, path: web::Path<String>, data: AppData) -> actix_web::Result<HttpResponse> {
async fn handle_download(
req: HttpRequest,
path: web::Path<String>,
data: AppData,
) -> actix_web::Result<HttpResponse> {
let file_code = path.into_inner();
if !util::is_ascii_alphanumeric(&file_code) {
return Ok(HttpResponse::NotFound().finish());
@ -65,8 +66,9 @@ async fn handle_download(req: HttpRequest, path: web::Path<String>, data: AppDat
if let Some(info) = info {
Ok(download::DownloadingFile {
file: File::open(storage_dir().join(file_code))?,
info: info.clone(),
}.into_response(&req))
info,
}
.into_response(&req))
} else {
Ok(HttpResponse::NotFound().finish())
}