cargo fmt
This commit is contained in:
@@ -33,7 +33,10 @@ pub async fn create_post(
|
|||||||
// Handle renaming
|
// Handle renaming
|
||||||
if let Some(ref old_slug) = payload.old_slug {
|
if let Some(ref old_slug) = payload.old_slug {
|
||||||
if old_slug != &payload.slug {
|
if old_slug != &payload.slug {
|
||||||
let old_file_path = state.data_dir.join("posts").join(format!("{}.md", old_slug));
|
let old_file_path = state
|
||||||
|
.data_dir
|
||||||
|
.join("posts")
|
||||||
|
.join(format!("{}.md", old_slug));
|
||||||
if old_file_path.exists() {
|
if old_file_path.exists() {
|
||||||
// If new path already exists and it's different from old path, error out
|
// If new path already exists and it's different from old path, error out
|
||||||
if file_path.exists() {
|
if file_path.exists() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use axum::{
|
use axum::{
|
||||||
Json,
|
Json,
|
||||||
extract::{Multipart, State, Path, Query},
|
extract::{Multipart, Path, Query, State},
|
||||||
http::{HeaderMap, StatusCode},
|
http::{HeaderMap, StatusCode},
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@@ -27,7 +27,7 @@ pub async fn delete_upload(
|
|||||||
check_auth(&headers, &state.admin_token)?;
|
check_auth(&headers, &state.admin_token)?;
|
||||||
|
|
||||||
let file_path = state.data_dir.join("uploads").join(&filename);
|
let file_path = state.data_dir.join("uploads").join(&filename);
|
||||||
|
|
||||||
// Security check to prevent directory traversal
|
// Security check to prevent directory traversal
|
||||||
if file_path.parent() != Some(&state.data_dir.join("uploads")) {
|
if file_path.parent() != Some(&state.data_dir.join("uploads")) {
|
||||||
return Err(AppError::BadRequest("Invalid filename".to_string()));
|
return Err(AppError::BadRequest("Invalid filename".to_string()));
|
||||||
|
|||||||
Reference in New Issue
Block a user