tangled
alpha
login
or
join now
nel.pet
/
pds-migrate
6
fork
atom
CLI tool for migrating PDS
6
fork
atom
overview
issues
pulls
pipelines
Fix blob migration
nel.pet
1 year ago
e24206ff
733c55c6
+59
-26
1 changed file
expand all
collapse all
unified
split
src
main.rs
+59
-26
src/main.rs
···
2
agent::atp_agent::{store::MemorySessionStore, AtpAgent},
3
app::bsky::actor::{get_preferences, put_preferences},
4
com::atproto::{
0
5
server::{create_account, get_service_auth},
6
sync::{get_blob, get_repo, list_blobs},
7
},
···
9
};
10
use atrium_xrpc_client::reqwest::ReqwestClient;
11
use std::{
12
-
io::{self, Write},
13
-
sync::Arc,
14
};
15
16
mod jwt;
···
246
}
247
};
248
249
-
while listed_blobs.cursor.is_some() {
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
250
for cid in listed_blobs.cids.iter() {
251
let blob = match old_agent
252
.api
···
277
}
278
};
279
}
280
-
281
-
listed_blobs = match old_agent
282
-
.api
283
-
.com
284
-
.atproto
285
-
.sync
286
-
.list_blobs(
287
-
list_blobs::ParametersData {
288
-
cursor: listed_blobs.cursor.clone(),
289
-
did: old_agent.did().await.unwrap(),
290
-
limit: None,
291
-
since: None,
292
-
}
293
-
.into(),
294
-
)
295
-
.await
296
-
{
297
-
Ok(response) => response,
298
-
Err(err) => {
299
-
println!("com.atproto.sync.listBlobs at old PDS failed due to error: {err}");
300
-
return;
301
-
}
302
-
};
303
}
304
println!("Blobs successfully migrated!");
305
···
2
agent::atp_agent::{store::MemorySessionStore, AtpAgent},
3
app::bsky::actor::{get_preferences, put_preferences},
4
com::atproto::{
5
+
repo::list_missing_blobs,
6
server::{create_account, get_service_auth},
7
sync::{get_blob, get_repo, list_blobs},
8
},
···
10
};
11
use atrium_xrpc_client::reqwest::ReqwestClient;
12
use std::{
13
+
io::{self, Write}, sync::Arc
0
14
};
15
16
mod jwt;
···
246
}
247
};
248
249
+
for cid in listed_blobs.cids.iter() {
250
+
let blob = match old_agent
251
+
.api
252
+
.com
253
+
.atproto
254
+
.sync
255
+
.get_blob(
256
+
get_blob::ParametersData {
257
+
cid: cid.to_owned(),
258
+
did: old_agent.did().await.unwrap(),
259
+
}
260
+
.into(),
261
+
)
262
+
.await
263
+
{
264
+
Ok(response) => response,
265
+
Err(err) => {
266
+
println!("com.atproto.sync.getBlob at current PDS failed due to error: {err}");
267
+
return;
268
+
}
269
+
};
270
+
271
+
match new_agent.api.com.atproto.repo.upload_blob(blob).await {
272
+
Ok(_) => (),
273
+
Err(err) => {
274
+
println!("com.atproto.repo.uploadBlob at new PDS failed due to error: {err}");
275
+
return;
276
+
}
277
+
};
278
+
}
279
+
280
+
let mut cursor = listed_blobs.cursor.clone();
281
+
while cursor.is_some() {
282
+
listed_blobs = match old_agent
283
+
.api
284
+
.com
285
+
.atproto
286
+
.sync
287
+
.list_blobs(
288
+
list_blobs::ParametersData {
289
+
cursor: cursor.clone(),
290
+
did: old_agent.did().await.unwrap(),
291
+
limit: None,
292
+
since: None,
293
+
}
294
+
.into(),
295
+
)
296
+
.await
297
+
{
298
+
Ok(response) => response,
299
+
Err(err) => {
300
+
println!("com.atproto.sync.listBlobs at old PDS failed due to error: {err}");
301
+
return;
302
+
}
303
+
};
304
+
305
for cid in listed_blobs.cids.iter() {
306
let blob = match old_agent
307
.api
···
332
}
333
};
334
}
335
+
cursor = listed_blobs.cursor.clone();
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
336
}
337
println!("Blobs successfully migrated!");
338