Index Integrity Verification Command
Overview
Theindex verify command performs a comprehensive integrity check of the Spacedrive index for any given path. It compares the actual filesystem state with what’s stored in the database and reports any discrepancies.
Usage
How It Works
The command performs three main steps:1. Ephemeral Indexing
Runs a fresh, in-memory index scan of the filesystem path to capture the current state:- Discovers all files and directories
- Extracts metadata (size, modified time, inode)
- Optionally generates content hashes (with
--verify-content)
2. Database Query
Queries the Spacedrive database for all indexed entries under the given path:- Uses closure table for efficient descendant lookup
- Resolves full paths for all entries
- Extracts stored metadata
3. Comparison & Reporting
Compares the two datasets and categorizes differences:| Issue Type | Description |
|---|---|
| Missing from Index | Files exist on filesystem but not in database |
| Stale in Index | Files exist in database but not on filesystem |
| Metadata Mismatch | Files exist in both but with incorrect size/time/inode |
| Hierarchy Error | Files have incorrect parent relationships |
Output Format
When to Use
Debugging Index Issues
If you suspect the index is out of sync with the filesystem:After Manual File Operations
If you’ve manually modified files outside Spacedrive:Performance Testing
To verify the watcher is working correctly:Pre-Sync Validation
Before syncing a library to ensure data integrity:Exit Codes
| Code | Meaning |
|---|---|
| 0 | Index is valid (no issues found) |
| 1 | Index has diverged (issues found) |
| 2 | Verification failed (error occurred) |
Use in Scripts
Performance Characteristics
| Path Size | Typical Duration | Memory Usage |
|---|---|---|
| 100 files | <1 second | ~10 MB |
| 1,000 files | 1-3 seconds | ~50 MB |
| 10,000 files | 10-30 seconds | ~200 MB |
| 100,000 files | 1-5 minutes | ~1 GB |
--verify-content:
- Add 50-200% time overhead (depends on file sizes)
- Requires reading file contents for hashing
Common Use Cases
1. Verify Location After Import
2. Debug Watcher Issues
3. Find Orphaned Entries
4. Validate After Bulk Operations
Troubleshooting
”Path does not exist”
- Ensure the path is correct and accessible
- Check permissions
”No entries found in database”
- Path might not be part of a managed location
- Run
sd-cli location listto see indexed locations
High number of “Missing from Index”
- Location watcher might be disabled
- Files were added manually without indexing
- Run
sd-cli location rescan <location-id>to fix
High number of “Stale in Index”
- Files were deleted manually
- Database not updated
- Consider running cleanup
API Access
The verification can also be triggered programmatically:Future Enhancements
--auto-fix: Automatically repair issues (add missing, remove stale)--watch: Continuously verify and report drift--json: Machine-readable output for automation--compare-with <snapshot>: Compare current state with previous snapshot--export-snapshot: Save current state for future comparison
