Expand description
§UpdateIndex
§File: Indexing/Store/UpdateIndex.rs
§Role in Air Architecture
Provides index update functionality for the File Indexer service, handling incremental updates to the index from file watching and manual trigger events.
§Primary Responsibility
Update the file index in response to file system changes, maintaining consistency between the in-memory index and the disk storage.
§Secondary Responsibilities
- Incremental file updates
- File deletion handling
- Index content re-indexing
- Symbol index updates
- Automatic index persistence
§Dependencies
External Crates:
tokio- Async file I/O operations
Internal Modules:
crate::Result- Error handling typecrate::AirError- Error typessuper::super::FileIndex- Index structure definitionssuper::StoreEntry- Index storage operationssuper::ScanFile- File scanning operationssuper::UpdateState- State update functions
§Dependents
Indexing::Watch::WatchFile- File watcher event handlersIndexing::mod::FileIndexer- Main file indexer implementation
§VSCode Pattern Reference
Inspired by VSCode’s incremental indexing in
src/vs/workbench/services/search/common/
§Security Considerations
- Path validation before updates
- File size limits enforced
- Symbolic link handling
§Performance Considerations
- Incremental updates minimize reindexing
- Debouncing rapid file changes
- Batch updates for multiple changes
- Efficient symbol index updates
§Error Handling Strategy
Update operations log warnings for individual failures and continue, ensuring a single file error doesn’t halt the entire update process.
§Thread Safety
Update operations acquire write locks on shared state and return results for persistence.
Structs§
- Debounced
Update - Debounced file update to prevent excessive re-indexing
- Repair
Result - Index repair result
- Update
Batch Result - Batch update result
- Watcher
Event Result - Watcher event processing result
Functions§
- Cleanup
Removed Files - Remove files from index that no longer exist
- Process
Watcher Event - Update index for changed files from file watcher
- Rebuild
Index - Rebuild index from scratch (full reindex)
- Update
File Content - Update index content for a file
- Update
Files Batch - Update multiple files in batch
- Update
Single File - Update index for a single file
- Validate
AndRepair Index - Validate index consistency and repair if needed