Skip to main content

Index Integrity Verification Command

Overview

The index 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:

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

Use in Scripts

Performance Characteristics

With --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 list to 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