···169169 </form>
170170 <div x-show="askForPlcToken" class="section">
171171 <form @submit.prevent="await signPlcOperation()">
172172- <h2>Please enter your PLCToken you received in an email</h2>
172172+ <h2>Please enter your PLC Token you received in an email</h2>
173173 <div class="form-group">
174174- <label for="plc-token">PLCToken:</label>
174174+ <label for="plc-token">PLC Token:</label>
175175 <input type="text" id="plc-token" name="plc-token" x-model="plcToken" required>
176176 </div>
177177 <div x-show="error" x-text="error" class="error-message"></div>
+50-5
src/pdsmoover.js
···3535 constructor() {
3636 this.oldAgent = null;
3737 this.newAgent = null;
3838+ this.missingBlobs = [];
3839 }
39404041 /**
···7778 await oldAgent.login({identifier: oldHandle, password: password, authFactorToken: twoFactorCode});
7879 }
79808080- safeStatusUpdate(statusUpdateHandler, 'Checking that the new PDS is an actual PDS');
8181+ safeStatusUpdate(statusUpdateHandler, 'Checking that the new PDS is an actual PDS (if the url is wrong this takes a while to error out)');
8182 const newAgent = new AtpAgent({service: newPdsUrl});
8283 const newHostDesc = await newAgent.com.atproto.server.describeServer();
8384 const newHostWebDid = newHostDesc.data.did;
···110111111112 await newAgent.login({
112113 identifier: usersDid,
113113- password,
114114+ password: password,
114115 });
115116116117 safeStatusUpdate(statusUpdateHandler, 'Migrating your repo');
···119120 encoding: 'application/vnd.ipld.car',
120121 });
121122123123+ let newAccountStatus = await newAgent.com.atproto.server.checkAccountStatus();
122124 safeStatusUpdate(statusUpdateHandler, 'Migrating your blobs');
123125124126 let blobCursor = undefined;
125127 let uploadedBlobs = 0;
126128 do {
127127- safeStatusUpdate(statusUpdateHandler, `Migrating blobs, ${uploadedBlobs}/${uploadedBlobs + 100}`);
128128- uploadedBlobs += 100;
129129+ safeStatusUpdate(statusUpdateHandler, `Migrating blobs: ${uploadedBlobs}/${newAccountStatus.data.expectedBlobs}`);
130130+129131 const listedBlobs = await oldAgent.com.atproto.sync.listBlobs({
130132 did: usersDid,
131133 cursor: blobCursor,
132134 limit: 100,
133135 });
136136+134137 for (const cid of listedBlobs.data.cids) {
135138 try {
136139 //TODO may move the status update here but would have it only update like every 10
···141144 await newAgent.com.atproto.repo.uploadBlob(blobRes.data, {
142145 encoding: blobRes.headers['content-type'],
143146 });
147147+ uploadedBlobs++;
148148+ if (uploadedBlobs % 10 === 0) {
149149+ safeStatusUpdate(statusUpdateHandler, `Migrating blobs: ${uploadedBlobs}/${newAccountStatus.data.expectedBlobs}`);
150150+ }
144151 } catch (error) {
145152 //TODO silently logging for now will do a missing blobs later
146153 console.error(error);
···149156 blobCursor = listedBlobs.data.cursor;
150157 } while (blobCursor);
151158152152- //TODO NEED to do some checking on the missing blobs here
159159+ newAccountStatus = await newAgent.com.atproto.server.checkAccountStatus();
160160+ if (newAccountStatus.data.expectedBlobs !== uploadedBlobs) {
161161+ let totalMissingBlobs = newAccountStatus.data.expectedBlobs - uploadedBlobs;
162162+ safeStatusUpdate(statusUpdateHandler, 'Looks like there are some missing blobs. Going to try and upload them now.');
163163+ //Probably should be shared between main blob uploader, but eh
164164+ let missingBlobCursor = undefined;
165165+ let missingUploadedBlobs = 0;
166166+ do {
167167+ safeStatusUpdate(statusUpdateHandler, `Migrating blobs: ${missingUploadedBlobs}/${totalMissingBlobs}`);
168168+169169+ const missingBlobs = await oldAgent.com.atproto.repo.listMissingBlobs({
170170+ did: usersDid,
171171+ cursor: missingBlobCursor,
172172+ limit: 100,
173173+ });
174174+175175+ for (const cid of missingBlobs.data.cids) {
176176+ try {
177177+ //TODO may move the status update here but would have it only update like every 10
178178+ const blobRes = await oldAgent.com.atproto.sync.getBlob({
179179+ cid,
180180+ });
181181+ await newAgent.com.atproto.repo.uploadBlob(blobRes.data, {
182182+ encoding: blobRes.headers['content-type'],
183183+ });
184184+ if (uploadedBlobs % 10 === 0) {
185185+ safeStatusUpdate(statusUpdateHandler, `Migrating blobs: ${uploadedBlobs}/${uploadedBlobs}`);
186186+ }
187187+ uploadedBlobs++;
188188+ } catch (error) {
189189+ //TODO silently logging for now will do a missing blobs later
190190+ console.error(error);
191191+ this.missingBlobs.push(cid);
192192+ }
193193+ }
194194+ missingBlobCursor = missingBlobs.data.cursor;
195195+ } while (missingBlobCursor);
196196+197197+ }
153198154199 const prefs = await oldAgent.app.bsky.actor.getPreferences();
155200 await newAgent.app.bsky.actor.putPreferences(prefs.data);