From b00c86dab0bd29b0c16f4242649144a50946dfac Mon Sep 17 00:00:00 2001 From: "Michaut.Francois" Date: Sun, 24 Aug 2025 19:49:44 -0300 Subject: [PATCH] Fix Default Config Filepath --- source/Config/Config.cpp | 13 ++++++------- source/Config/ServerConfig.cpp | 5 ++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/Config/Config.cpp b/source/Config/Config.cpp index 90d747f..adc084f 100644 --- a/source/Config/Config.cpp +++ b/source/Config/Config.cpp @@ -4,7 +4,7 @@ ** Author Francois Michaut ** ** Started on Tue Sep 13 11:29:35 2022 Francois Michaut -** Last update Fri Aug 22 20:39:00 2025 Francois Michaut +** Last update Sun Aug 24 19:46:07 2025 Francois Michaut ** ** FileShareConfig.cpp : FileShareConfig implementation */ @@ -22,12 +22,11 @@ const char * const DEFAULT_PATH = "~/.fsp/default_config"; namespace FileShare { - Config::Config() { - if (m_downloads_folder.empty()) { - // TODO: replace by cross-plateform way of getting the dowloads folder - m_downloads_folder = FileShare::Utils::resolve_home_component("~/Downloads/FileShare"); - } - } + Config::Config() : + m_filepath(FileShare::Utils::resolve_home_component(DEFAULT_PATH)), + // TODO: replace by cross-plateform way of getting the dowloads folder + m_downloads_folder(FileShare::Utils::resolve_home_component("~/Downloads/FileShare")) + {} Config::Config(bool /*_*/) {} diff --git a/source/Config/ServerConfig.cpp b/source/Config/ServerConfig.cpp index 452ff8e..ded6846 100644 --- a/source/Config/ServerConfig.cpp +++ b/source/Config/ServerConfig.cpp @@ -4,7 +4,7 @@ ** Author Francois Michaut ** ** Started on Wed Aug 6 15:19:24 2025 Francois Michaut -** Last update Fri Aug 22 20:42:47 2025 Francois Michaut +** Last update Sun Aug 24 19:48:12 2025 Francois Michaut ** ** ServerConfig.cpp : Server Configuration Implementation */ @@ -24,6 +24,7 @@ const char * const DEFAULT_PATH = "~/.fsp/server_config"; namespace FileShare { ServerConfig::ServerConfig() : + m_filepath(FileShare::Utils::resolve_home_component(DEFAULT_PATH)), m_uuid("0000-0000-0000-0000") // TODO: Generate Random UUID {} @@ -59,6 +60,8 @@ namespace FileShare { std::ifstream file(config.m_filepath, std::ios_base::binary | std::ios_base::in); cereal::BinaryInputArchive archive(file); + // TODO: Will crash if file doesn't exist. Do we want to create it ? + // It could also be an error if the config is missing -> TBD archive(config); // TODO: Need to validate config - if someone messes up the file, we could have problems // (Or if private_keys_dir contains ~, it needs to be expanded)