mirror of
https://github.com/Dangoware/confetti-box.git
synced 2025-04-19 23:32:58 -05:00
Create directories if they do not exist
This commit is contained in:
parent
52de2ccbe4
commit
84e2e4787d
1 changed files with 10 additions and 2 deletions
12
src/main.rs
12
src/main.rs
|
@ -2,13 +2,13 @@ mod database;
|
||||||
mod strings;
|
mod strings;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
|
||||||
use std::{path::Path, sync::{Arc, RwLock}};
|
use std::{fs, path::Path, sync::{Arc, RwLock}};
|
||||||
use blake3::Hash;
|
use blake3::Hash;
|
||||||
use chrono::{DateTime, TimeDelta, Utc};
|
use chrono::{DateTime, TimeDelta, Utc};
|
||||||
use database::{clean_loop, Database, MochiFile};
|
use database::{clean_loop, Database, MochiFile};
|
||||||
use log::info;
|
use log::info;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
data::{Limits, ToByteUnit}, form::Form, fs::{FileServer, Options, TempFile}, get, http::{ContentType, RawStr}, post, response::{content::{RawCss, RawJavaScript}, status::NotFound, Redirect}, routes, serde::{json::Json, Serialize}, tokio::{self, fs::File, io::AsyncReadExt}, Config, FromForm, State
|
config, data::{Limits, ToByteUnit}, form::Form, fs::{FileServer, Options, TempFile}, get, http::{ContentType, RawStr}, post, response::{content::{RawCss, RawJavaScript}, status::NotFound, Redirect}, routes, serde::{json::Json, Serialize}, tokio::{self, fs::File, io::AsyncReadExt}, Config, FromForm, State
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use strings::{parse_time_string, to_pretty_time};
|
use strings::{parse_time_string, to_pretty_time};
|
||||||
|
@ -276,6 +276,14 @@ async fn main() {
|
||||||
let config = Settings::open(&"./settings.toml")
|
let config = Settings::open(&"./settings.toml")
|
||||||
.expect("Could not open settings file");
|
.expect("Could not open settings file");
|
||||||
|
|
||||||
|
if !config.temp_dir.try_exists().is_ok_and(|e| e) {
|
||||||
|
fs::create_dir_all(config.temp_dir.clone()).expect("Failed to create temp directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
if !config.file_dir.try_exists().is_ok_and(|e| e) {
|
||||||
|
fs::create_dir_all(config.file_dir.clone()).expect("Failed to create file directory");
|
||||||
|
}
|
||||||
|
|
||||||
// Set rocket configuration settings
|
// Set rocket configuration settings
|
||||||
let rocket_config = Config {
|
let rocket_config = Config {
|
||||||
address: config.server.address.parse().expect("IP address invalid"),
|
address: config.server.address.parse().expect("IP address invalid"),
|
||||||
|
|
Loading…
Reference in a new issue