Load existing index or build new one from file sources. Validates index integrity and performs incremental updates if needed.
(self)
| 51 | self.file_metadata: Dict[str, Dict[str, Any]] = {} |
| 52 | |
| 53 | def load(self) -> None: |
| 54 | """ |
| 55 | Load existing index or build new one from file sources. |
| 56 | Validates index integrity and performs incremental updates if needed. |
| 57 | """ |
| 58 | if self.index_path and os.path.exists(self.index_path): |
| 59 | logger.info(f"Loading existing index from {self.index_path}") |
| 60 | self._load_from_file() |
| 61 | |
| 62 | # Validate and update if files changed |
| 63 | if self._validate_and_update_index(): |
| 64 | logger.info("Index updated due to file changes") |
| 65 | self.save() |
| 66 | else: |
| 67 | logger.info("Building new index from file sources") |
| 68 | self._build_index_from_sources() |
| 69 | if self.index_path: |
| 70 | self.save() |
| 71 | |
| 72 | def save(self) -> None: |
| 73 | """Persist the memory index to disk""" |
no test coverage detected