Automatically create uploads directory

This commit is contained in:
Ivan R. 2024-11-05 20:32:42 +05:00
parent df367d53c7
commit 2e25aee255
Signed by: lumin
GPG key ID: 9B2CA5D12844D4D0

View file

@ -4,7 +4,7 @@ use axum::{
}; };
use log::info; use log::info;
use sqlx::postgres::PgPoolOptions; use sqlx::postgres::PgPoolOptions;
use std::sync::Arc; use std::{fs, sync::Arc};
use tokio::signal; use tokio::signal;
use tower_http::services::ServeDir; use tower_http::services::ServeDir;
@ -20,6 +20,9 @@ mod web;
async fn main() { async fn main() {
env_logger::init(); env_logger::init();
let images_dir = CONFIG.uploads_dir.join("images");
fs::create_dir_all(images_dir).unwrap();
let pool = PgPoolOptions::new() let pool = PgPoolOptions::new()
.max_connections(CONFIG.database.max_connections) .max_connections(CONFIG.database.max_connections)
.connect(&CONFIG.database.url) .connect(&CONFIG.database.url)