diff --git a/db/c_nostr_relay.db b/db/c_nostr_relay.db index a42a536..74fe5b9 100644 Binary files a/db/c_nostr_relay.db and b/db/c_nostr_relay.db differ diff --git a/relay.pid b/relay.pid index 13e1251..eae82bf 100644 --- a/relay.pid +++ b/relay.pid @@ -1 +1 @@ -949770 +954022 diff --git a/src/main.c b/src/main.c index a287d02..aa5fdad 100644 --- a/src/main.c +++ b/src/main.c @@ -3132,6 +3132,66 @@ int main(int argc, char* argv[]) { return 1; } + // Store metadata about actual paths used (for reference, not for configuration lookup) + if (database_path_override) { + // Convert to absolute path and normalize + char actual_db_path[1024]; + if (database_path_override[0] == '/') { + // Already absolute + strncpy(actual_db_path, database_path_override, sizeof(actual_db_path) - 1); + } else { + // Make absolute by prepending current working directory + char cwd[1024]; + if (getcwd(cwd, sizeof(cwd))) { + // Handle the case where path starts with ./ + const char* clean_path = database_path_override; + if (strncmp(database_path_override, "./", 2) == 0) { + clean_path = database_path_override + 2; + } + snprintf(actual_db_path, sizeof(actual_db_path), "%s/%s", cwd, clean_path); + } else { + strncpy(actual_db_path, database_path_override, sizeof(actual_db_path) - 1); + } + } + actual_db_path[sizeof(actual_db_path) - 1] = '\0'; + + if (set_database_config("database_location", actual_db_path, "system") == 0) { + log_info("Stored database location metadata"); + } else { + log_warning("Failed to store database location metadata"); + } + } + + // Store metadata about configuration file path used + if (strlen(g_config_manager.config_file_path) > 0) { + // Convert to absolute path and normalize + char actual_config_path[1024]; + if (g_config_manager.config_file_path[0] == '/') { + // Already absolute + strncpy(actual_config_path, g_config_manager.config_file_path, sizeof(actual_config_path) - 1); + } else { + // Make absolute by prepending current working directory + char cwd[1024]; + if (getcwd(cwd, sizeof(cwd))) { + // Handle the case where path starts with ./ + const char* clean_path = g_config_manager.config_file_path; + if (strncmp(g_config_manager.config_file_path, "./", 2) == 0) { + clean_path = g_config_manager.config_file_path + 2; + } + snprintf(actual_config_path, sizeof(actual_config_path), "%s/%s", cwd, clean_path); + } else { + strncpy(actual_config_path, g_config_manager.config_file_path, sizeof(actual_config_path) - 1); + } + } + actual_config_path[sizeof(actual_config_path) - 1] = '\0'; + + if (set_database_config("config_location", actual_config_path, "system") == 0) { + log_info("Stored configuration location metadata"); + } else { + log_warning("Failed to store configuration location metadata"); + } + } + // Apply command line overrides AFTER configuration system is initialized if (port != DEFAULT_PORT) { log_info("Applying port override from command line"); diff --git a/test_clean_paths.db b/test_clean_paths.db new file mode 100644 index 0000000..d62063d Binary files /dev/null and b/test_clean_paths.db differ diff --git a/test_metadata.db b/test_metadata.db new file mode 100644 index 0000000..4e36afd Binary files /dev/null and b/test_metadata.db differ