Expand description
§StoreEntry
§File: Indexing/Store/StoreEntry.rs
§Role in Air Architecture
Provides index storage functionality for the File Indexer service, handling serialization and persistence of the file index to disk.
§Primary Responsibility
Store the file index to disk with atomic writes and corruption recovery mechanisms.
§Secondary Responsibilities
- Load index from disk with validation
- Backup corrupted indexes automatically
- Atomic writes using temp files
- Index integrity verification
§Dependencies
External Crates:
serde_json- JSON serialization/deserializationtokio- Async file I/O operations
Internal Modules:
crate::Result- Error handling typecrate::AirError- Error typessuper::super::FileIndex- Index structure definitionssuper::super::State::CreateState- State creation utilities
§Dependents
Indexing::mod::FileIndexer- Main file indexer implementation
§VSCode Pattern Reference
Inspired by VSCode’s index storage in
src/vs/workbench/services/search/common/
§Security Considerations
- Atomic writes prevent partial index corruption
- Permission checking on index directory
- Path traversal protection
§Performance Considerations
- Temp file pattern for atomic writes
- Lazy loading of in-memory index
- Efficient serialization with serde
§Error Handling Strategy
Storage operations return detailed error messages for failures and automatically backup corrupted indexes when loading fails.
§Thread Safety
Storage operations use async file I/O and return results that can be safely merged into shared Ar c<RwLock<>> state.
Functions§
- Backup
Corrupted Index - Backup corrupted index before creating new one
- Cleanup
OldBackups - Clean up old backup files
- Ensure
Index Directory - Ensure index directory exists with proper error handling
- GetIndex
File Path - Get index file path
- GetIndex
File Size - Get index file size in bytes
- Index
File Exists - Check if index file exists and is readable
- Load
Index - Load index from disk with corruption detection
- Load
Index With Recovery - Load index with automatic recovery on corruption
- Load
OrCreate Index - Load or create index with corruption detection
- Save
Index - Save index to disk with atomic write
- Validate
Index Format - Validate index file format before loading