Skip to content

Commit

Permalink
Try to attempt the game state directory if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
myOmikron committed Apr 26, 2023
1 parent d67c0c4 commit 123709d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async fn main() -> Result<(), String> {
cli::migrate::run_migrate_custom(
cli_config::DatabaseConfig {
last_migration_table_name: None,
driver: cli_config::DatabaseDriver::Postgres {
driver: DatabaseDriver::Postgres {
host: conf.database.host,
port: conf.database.port,
name: conf.database.name,
Expand Down
9 changes: 9 additions & 0 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! This module holds the server definition
use std::fs::{create_dir_all, set_permissions, Permissions};
use std::net::SocketAddr;
use std::os::unix::fs::PermissionsExt;
use std::path::Path;

use actix_toolbox::tb_middleware::{
setup_logging_mw, DBSessionStore, LoggingMiddlewareConfig, PersistentSession, SessionMiddleware,
Expand Down Expand Up @@ -71,6 +74,12 @@ pub async fn start_server(
return Err(StartServerError::InvalidSecretKey);
}

let game_data = Path::new(&config.server.game_data_path);
if !game_data.exists() {
create_dir_all(game_data)?;
set_permissions(game_data, Permissions::from_mode(0o700))?;
}

let runtime_settings = RuntimeSettings {
game_data_path: config.server.game_data_path.clone(),
};
Expand Down

0 comments on commit 123709d

Please sign in to comment.