updated theming and fixed warnings

This commit is contained in:
2026-03-26 10:35:28 +01:00
parent 85549d41f8
commit 63cc84916e
11 changed files with 119 additions and 115 deletions

View File

@@ -1,17 +1,16 @@
use axum::{
Json,
extract::{Multipart, State},
http::HeaderMap,
response::IntoResponse,
Json,
};
use std::{fs, sync::Arc};
use tracing::{error, info, warn};
use crate::{
AppState,
auth::check_auth,
error::AppError,
models::{FileInfo, UploadResponse},
AppState,
};
pub async fn list_uploads(
@@ -57,12 +56,12 @@ pub async fn upload_file(
info!("Processing upload for: {}", file_name);
let slugified_name = slug::slugify(&file_name);
let extension = std::path::Path::new(&file_name)
.extension()
.and_then(|e| e.to_str())
.unwrap_or("");
let final_name = if !extension.is_empty() {
format!("{}.{}", slugified_name, extension)
} else {
@@ -79,7 +78,12 @@ pub async fn upload_file(
file_path
};
let final_name_str = final_path.file_name().unwrap().to_str().unwrap().to_string();
let final_name_str = final_path
.file_name()
.unwrap()
.to_str()
.unwrap()
.to_string();
let data = match field.bytes().await {
Ok(bytes) => bytes,
@@ -91,7 +95,10 @@ pub async fn upload_file(
if let Err(e) = fs::write(&final_path, &data) {
error!("Failed to write file to {:?}: {}", final_path, e);
return Err(AppError::Internal("Write error".to_string(), Some(e.to_string())));
return Err(AppError::Internal(
"Write error".to_string(),
Some(e.to_string()),
));
}
info!("File uploaded successfully to {:?}", final_path);
@@ -102,4 +109,4 @@ pub async fn upload_file(
warn!("Upload failed: no file found in multipart stream");
Err(AppError::BadRequest("No file found".to_string()))
}
}