From 3ae6d6dbd5b2b54e184d8ff6bb55f8a68be446b1 Mon Sep 17 00:00:00 2001 From: agessaman Date: Mon, 29 Dec 2025 10:46:08 -0800 Subject: [PATCH] Update database path configuration for web viewer - Added db_path configuration options in config.ini.example for both the main bot and web viewer - Updated BotDataViewer and BotIntegration classes to retrieve the database path from the new Web_Viewer section --- config.ini.example | 8 ++++++++ modules/web_viewer/app.py | 12 ++++++------ modules/web_viewer/integration.py | 10 +++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/config.ini.example b/config.ini.example index e4c5ed8..a915c7d 100644 --- a/config.ini.example +++ b/config.ini.example @@ -108,6 +108,10 @@ startup_advert = false # false: Manual mode - no automatic actions, use !repeater commands to manage contacts (default) auto_manage_contacts = false +# Database path for main bot database +# Default: meshcore_bot.db +db_path = meshcore_bot.db + [Localization] # Language code for bot responses (en, es, es-MX, es-ES, fr, de, ja, etc.) # Default: en (English) @@ -736,6 +740,10 @@ debug = false # false: Start web viewer manually (recommended) auto_start = false +# Database path for web viewer data +# Default: bot_data.db +db_path = bot_data.db + #################################################################################################### # # # Service Plugins Config # diff --git a/modules/web_viewer/app.py b/modules/web_viewer/app.py index 9659348..baa102e 100644 --- a/modules/web_viewer/app.py +++ b/modules/web_viewer/app.py @@ -181,7 +181,7 @@ class BotDataViewer: conn = None try: # Get database path from config - db_path = self.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: @@ -398,7 +398,7 @@ class BotDataViewer: cutoff_time = time.time() - (60 * 60) # 60 minutes ago # Get database path - db_path = self.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: @@ -1430,7 +1430,7 @@ class BotDataViewer: import json # Get database path - db_path = self.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: @@ -1549,7 +1549,7 @@ class BotDataViewer: cutoff_time = time.time() - (days_to_keep * 24 * 60 * 60) # Get database path - db_path = self.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: @@ -2036,7 +2036,7 @@ class BotDataViewer: # Get database file size import os - db_path = self.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: db_path = str(validate_safe_path(db_path, base_dir=str(self.bot_root), allow_absolute=False)) @@ -2098,7 +2098,7 @@ class BotDataViewer: # Get initial database size import os - db_path = self.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: db_path = str(validate_safe_path(db_path, base_dir=str(self.bot_root), allow_absolute=False)) diff --git a/modules/web_viewer/integration.py b/modules/web_viewer/integration.py index 35bc678..b60bf49 100644 --- a/modules/web_viewer/integration.py +++ b/modules/web_viewer/integration.py @@ -35,7 +35,7 @@ class BotIntegration: import sqlite3 # Get database path from config - db_path = self.bot.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.bot.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: @@ -107,7 +107,7 @@ class BotIntegration: serializable_data = self._make_json_serializable(packet_data) # Store in database for web viewer to read - db_path = self.bot.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.bot.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: base_dir = str(self.bot.bot_root) if hasattr(self.bot, 'bot_root') else '.' @@ -164,7 +164,7 @@ class BotIntegration: serializable_data = self._make_json_serializable(command_data) # Store in database for web viewer to read - db_path = self.bot.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.bot.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: base_dir = str(self.bot.bot_root) if hasattr(self.bot, 'bot_root') else '.' @@ -198,7 +198,7 @@ class BotIntegration: serializable_data = self._make_json_serializable(routing_data) # Store in database for web viewer to read - db_path = self.bot.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.bot.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: base_dir = str(self.bot.bot_root) if hasattr(self.bot, 'bot_root') else '.' @@ -229,7 +229,7 @@ class BotIntegration: cutoff_time = time.time() - (days_to_keep * 24 * 60 * 60) - db_path = self.bot.config.get('Database', 'path', fallback='bot_data.db') + db_path = self.bot.config.get('Web_Viewer', 'db_path', fallback='bot_data.db') # Validate and resolve database path relative to bot root try: base_dir = str(self.bot.bot_root) if hasattr(self.bot, 'bot_root') else '.'