Module StoreEntry

Module StoreEntry 

Source
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/deserialization
  • tokio - Async file I/O operations

Internal Modules:

  • crate::Result - Error handling type
  • crate::AirError - Error types
  • super::super::FileIndex - Index structure definitions
  • super::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§

BackupCorruptedIndex
Backup corrupted index before creating new one
CleanupOldBackups
Clean up old backup files
EnsureIndexDirectory
Ensure index directory exists with proper error handling
GetIndexFilePath
Get index file path
GetIndexFileSize
Get index file size in bytes
IndexFileExists
Check if index file exists and is readable
LoadIndex
Load index from disk with corruption detection
LoadIndexWithRecovery
Load index with automatic recovery on corruption
LoadOrCreateIndex
Load or create index with corruption detection
SaveIndex
Save index to disk with atomic write
ValidateIndexFormat
Validate index file format before loading