check_repository()
Runs a comprehensive check on the repository.Parameters
repo: The repository to checkopts: Check optionstrees: List of tree IDs to check
Returns
ReturnsCheckResults containing any errors or warnings found.
Errors
- If the repository is corrupted
- If data validation fails
CheckOptions
Configuration options for the check operation.Don’t verify the data saved in the cache. Conflicts with
no_cache.Also read and check pack files (thorough check).
Read only a subset of the data. Allowed values:
"all": Read all pack files"n/m": Read specific part (e.g., “1/5” for first fifth)"x%": Random subset by percentage (e.g., “10%”)- Size value: Random subset by size (e.g., “250MiB”)
read_data to be enabled.ReadSubsetOption
Specifies which subset of packs to read during check.Variants
All
Read all pack files.
Percentage(f64)
Read a random subset with approximately the given percentage of total size.
Size(u64)
Read a random subset with approximately the given size in bytes.
IdSubSet((u32, u32))
Read a subset based on pack IDs: using (1,n) .. (n,n) in separate runs covers all packs.
CheckResults
Results from a check operation.Methods
is_ok()
Returns whether severe errors were found.CheckErrorLevel::Error.
CheckErrorLevel
Severity levels of problems identified by check.Warn
A warning: Something is strange and should be corrected, but repository integrity is not affected.
Error
An error: Something in the repository is not as it should be.
CheckError
Describes specific errors found during check operations. Common error types include:- Pack errors: Missing packs, size mismatches, hash mismatches
- Index errors: Duplicate packs, inconsistent index data
- Blob errors: Missing blobs, incorrect blob references
- Tree errors: Missing or invalid directory trees
- Cache errors: Mismatched cache data
Example
Check Types
Metadata Check (Fast)
Withoutread_data, check verifies:
- Index file consistency
- Pack file existence and sizes
- Snapshot metadata
- Tree structure references
- Cache consistency (unless
trust_cacheis set)
Data Check (Thorough)
Withread_data, check additionally:
- Reads and verifies pack file contents
- Validates blob checksums
- Verifies compression and encryption
- Checks pack headers
Partial Data Check
Useread_data_subset to check a portion of data:
Notes
- Regular checks help detect corruption early
- Metadata checks are fast and can run frequently
- Full data checks are thorough but slower
- Use subset checking for large repositories
- Check validates both hot and cold storage in hot/cold repositories
- Cache verification ensures cached data matches backend data