Update the storage root and database path when network context changes.
(self, data_root: Optional[str], db_path: Optional[str])
| 108 | logger.info(f"DatabaseManager initialized: {self.db_path}") |
| 109 | |
| 110 | def configure_storage(self, data_root: Optional[str], db_path: Optional[str]): |
| 111 | """Update the storage root and database path when network context changes.""" |
| 112 | updated = False |
| 113 | with self.lock: |
| 114 | if data_root and data_root != self.datadir: |
| 115 | self.datadir = data_root |
| 116 | updated = True |
| 117 | if db_path and db_path != self.db_path: |
| 118 | self.db_path = db_path |
| 119 | updated = True |
| 120 | self.netkb_csv = os.path.join(self.datadir, 'netkb.csv') |
| 121 | if updated: |
| 122 | os.makedirs(os.path.dirname(self.db_path), exist_ok=True) |
| 123 | |
| 124 | if updated: |
| 125 | self._init_database() |
| 126 | logger.info(f"Database storage configured: root={self.datadir}, db={self.db_path}") |
| 127 | |
| 128 | @contextmanager |
| 129 | def get_connection(self): |
no test coverage detected