Add ownership snapshot sync

This commit is contained in:
Rasyidan Akbar F. 2026-03-31 19:28:13 +07:00
commit 8404b27628
13 changed files with 1415 additions and 42 deletions

View file

@ -258,6 +258,7 @@ const KNOWN_CONFIG_KEYS: &[&str] = &[
"cache.quote_ttl",
"cache.fundamental_ttl",
"ownership.db_path",
"ownership.snapshot_manifest",
];
/// Validates a config key and value before writing
@ -302,6 +303,10 @@ fn normalize_config_value(key: &str, value: &str) -> Result<toml::Value, IdxErro
// Ownership DB path is free-form and may be absolute or relative.
Ok(toml::Value::String(value.to_string()))
}
"ownership.snapshot_manifest" => {
// Snapshot manifest can be an absolute/relative path or a URL.
Ok(toml::Value::String(value.to_string()))
}
"general.color" => {
if !value.eq_ignore_ascii_case("true") && !value.eq_ignore_ascii_case("false") {
return Err(IdxError::InvalidInput(format!(
@ -556,6 +561,24 @@ mod tests {
assert!(super::validate_config_key_value("ownership.db_path", "data/ownership.db").is_ok());
}
#[test]
fn validate_accepts_ownership_snapshot_manifest() {
assert!(
super::validate_config_key_value(
"ownership.snapshot_manifest",
"https://example.com/latest.json"
)
.is_ok()
);
assert!(
super::validate_config_key_value(
"ownership.snapshot_manifest",
"snapshots/latest.json"
)
.is_ok()
);
}
#[test]
fn validate_accepts_valid_color() {
assert!(super::validate_config_key_value("general.color", "true").is_ok());