1
0

fix gpt memory dl

This commit is contained in:
2026-03-02 15:53:13 +09:00
parent 9f8c8d9f90
commit 639d619688

View File

@@ -51,6 +51,47 @@ pub async fn get_memory(download: bool) -> Result<()> {
let pds = session.pds.as_deref().unwrap_or("bsky.social"); let pds = session.pds.as_deref().unwrap_or("bsky.social");
let client = XrpcClient::new_bot(pds); let client = XrpcClient::new_bot(pds);
if download {
// Download all memory records
let mut cursor: Option<String> = None;
let mut count = 0;
loop {
let mut params: Vec<(&str, &str)> = vec![
("repo", &session.did),
("collection", COLLECTION_MEMORY),
("limit", "100"),
];
let cursor_val;
if let Some(ref c) = cursor {
cursor_val = c.clone();
params.push(("cursor", &cursor_val));
}
let result: ListRecordsResponse = client
.query_auth(
&com_atproto_repo::LIST_RECORDS,
&params,
&session.access_jwt,
)
.await?;
let batch = result.records.len();
for record in &result.records {
let rkey = record.uri.split('/').next_back().unwrap_or("unknown");
save_record(&session.did, COLLECTION_MEMORY, rkey, record)?;
count += 1;
}
match result.cursor {
Some(c) if batch > 0 => cursor = Some(c),
_ => break,
}
}
println!("Downloaded {} memory records", count);
} else {
// Show latest only
let result: ListRecordsResponse = client let result: ListRecordsResponse = client
.query_auth( .query_auth(
&com_atproto_repo::LIST_RECORDS, &com_atproto_repo::LIST_RECORDS,
@@ -64,20 +105,8 @@ pub async fn get_memory(download: bool) -> Result<()> {
) )
.await?; .await?;
let record = result let record = result.records.first().context("No memory records found")?;
.records
.first()
.context("No memory records found")?;
println!("{}", serde_json::to_string_pretty(&record.value)?); println!("{}", serde_json::to_string_pretty(&record.value)?);
if download {
let rkey = record
.uri
.split('/')
.next_back()
.unwrap_or("unknown");
save_record(&session.did, COLLECTION_MEMORY, rkey, record)?;
} }
Ok(()) Ok(())