fix translate
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user