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