MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / configure_storage

Method configure_storage

db_manager.py:110–126  ·  view source on GitHub ↗

Update the storage root and database path when network context changes.

(self, data_root: Optional[str], db_path: Optional[str])

Source from the content-addressed store, hash-verified

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):

Callers 1

_configure_databaseMethod · 0.80

Calls 2

_init_databaseMethod · 0.95
infoMethod · 0.80

Tested by

no test coverage detected