Skip to content

Commit

Permalink
fix: directory shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
sargon64 committed Jan 14, 2024
1 parent 6fb9c29 commit 89ea0e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub struct Key([u8; 1024]);
lazy_static::lazy_static! {
pub static ref KEY: Arc<Key> = {
if !Path::new("./data/secret.key").exists() {
let _ = std::fs::create_dir(Path::new("./data"));
let _ = std::fs::create_dir_all(Path::new("./data"));
let mut rng = rand::thread_rng();
let key: Vec<u8> = (0..1024).map(|_| rng.gen::<u8>()).collect();
#[allow(clippy::panic)]
Expand Down Expand Up @@ -215,7 +215,10 @@ async fn main() -> anyhow::Result<()> {

safety_checks();

let _ = std::fs::create_dir(Path::new("./data/cdn"));
let _ = std::fs::create_dir_all(Path::new("./data/cdn"));

// force the key to be generated
let _ = KEY.clone();

let pool = PgPoolOptions::new()
.min_connections(5)
Expand Down
2 changes: 1 addition & 1 deletion src/mods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ pub async fn _upload_mod(auth: &str, body: Vec<u8>) -> Response {
}
};

match std::fs::create_dir(format!("./data/cdn/{}", &db_mod.id)) {
match std::fs::create_dir_all(format!("./data/cdn/{}", &db_mod.id)) {
Ok(_) => {}
Err(e) => {
if e.kind() != std::io::ErrorKind::AlreadyExists {
Expand Down

0 comments on commit 89ea0e4

Please sign in to comment.