fix translate

This commit is contained in:
2026-01-18 17:34:30 +09:00
parent 97bcd13a8d
commit 7fd93747f7
4 changed files with 37 additions and 21 deletions

View File

@@ -323,8 +323,10 @@ pub async fn sync_to_local(output: &str) -> Result<()> {
let collection_dir = format!("{}/{}", did_dir, collection);
fs::create_dir_all(&collection_dir)?;
let mut rkeys: Vec<String> = Vec::new();
for record in &list.records {
let rkey = record.uri.split('/').last().unwrap_or("unknown");
rkeys.push(rkey.to_string());
let record_path = format!("{}/{}.json", collection_dir, rkey);
let record_json = serde_json::json!({
"uri": record.uri,
@@ -334,6 +336,12 @@ pub async fn sync_to_local(output: &str) -> Result<()> {
fs::write(&record_path, serde_json::to_string_pretty(&record_json)?)?;
println!("Saved: {}", record_path);
}
// Create index.json with list of rkeys
let index_path = format!("{}/index.json", collection_dir);
fs::write(&index_path, serde_json::to_string_pretty(&rkeys)?)?;
println!("Saved: {}", index_path);
println!("Synced {} records from {}", list.records.len(), collection);
}