···
const migratedBlobs: string[] = [];
const failedBlobs: Array<{ cid: string; error: string }> = [];
const migrationLogs: string[] = [];
182
+
let totalBlobs = 0;
185
+
// First count total blobs
186
+
console.log("Starting blob count...");
188
+
const listedBlobs = await oldAgent.com.atproto.sync.listBlobs({
190
+
cursor: blobCursor,
192
+
const newBlobs = listedBlobs.data.cids.length;
193
+
totalBlobs += newBlobs;
195
+
console.log(`Blob count page ${pageCount}: found ${newBlobs} blobs, total so far: ${totalBlobs}`);
196
+
migrationLogs.push(`Blob count page ${pageCount}: found ${newBlobs} blobs, total so far: ${totalBlobs}`);
198
+
if (!listedBlobs.data.cursor) {
199
+
console.log("No more cursor, finished counting blobs");
202
+
blobCursor = listedBlobs.data.cursor;
203
+
} while (blobCursor);
205
+
// Reset cursor for actual migration
206
+
blobCursor = undefined;
207
+
let processedBlobs = 0;
···
228
+
console.log(`Processing blob page ${pageCount}: ${listedBlobs.data.cids.length} blobs`);
229
+
migrationLogs.push(`Processing blob page ${pageCount}: ${listedBlobs.data.cids.length} blobs`);
for (const cid of listedBlobs.data.cids) {
const blobRes = await withRetry(
···
await handleBlobUpload(newAgent, blobRes, cid);
219
-
const log = `Successfully migrated blob: ${cid}`;
221
-
migrationLogs.push(log);
251
+
const progressLog = `Migrating blob ${processedBlobs} of ${totalBlobs}: ${cid}`;
252
+
console.log(progressLog);
253
+
migrationLogs.push(progressLog);
const errorMsg = error instanceof Error ? error.message : String(error);
console.error(`Failed to migrate blob ${cid}:`, error);
···
migrationLogs.push(`Failed to migrate blob ${cid}: ${errorMsg}`);
265
+
if (!listedBlobs.data.cursor) {
266
+
console.log("No more cursor, finished processing blobs");
267
+
migrationLogs.push("No more cursor, finished processing blobs");
blobCursor = listedBlobs.data.cursor;
···
271
-
const completionMessage = `Data migration completed: ${migratedBlobs.length} blobs migrated${failedBlobs.length > 0 ? `, ${failedBlobs.length} failed` : ''}`;
309
+
const completionMessage = `Data migration completed: ${migratedBlobs.length} blobs migrated${failedBlobs.length > 0 ? `, ${failedBlobs.length} failed` : ''} (${pageCount} pages processed)`;
console.log(completionMessage);
migrationLogs.push(completionMessage);