Module UpdateIndex

Module UpdateIndex 

Source
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 type
  • crate::AirError - Error types
  • super::super::FileIndex - Index structure definitions
  • super::StoreEntry - Index storage operations
  • super::ScanFile - File scanning operations
  • super::UpdateState - State update functions

§Dependents

  • Indexing::Watch::WatchFile - File watcher event handlers
  • Indexing::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§

DebouncedUpdate
Debounced file update to prevent excessive re-indexing
RepairResult
Index repair result
UpdateBatchResult
Batch update result
WatcherEventResult
Watcher event processing result

Functions§

CleanupRemovedFiles
Remove files from index that no longer exist
ProcessWatcherEvent
Update index for changed files from file watcher
RebuildIndex
Rebuild index from scratch (full reindex)
UpdateFileContent
Update index content for a file
UpdateFilesBatch
Update multiple files in batch
UpdateSingleFile
Update index for a single file
ValidateAndRepairIndex
Validate index consistency and repair if needed