+ Migrate your data
- Tangled has a new record format, so your data needs to be migrated before you can keep using
- Tangled
+ Tangled now stores your data in a new record format. Migrate it to keep using Tangled
{#if auth.currentUser}as {auth.currentUser.handle} {/if}. It's safe to try again if something goes wrong.
+ >{/if}. If anything fails, you can safely try again.
- {#if status}
-
-
{status}
- {#if progress?.phase === "blobs" || progress?.phase === "importing"}
-
- {/if}
-
- {/if}
-
-
+
{#if needsGrant}
-
- Sign in again to allow it
+
+ Sign in again to grant permission
{:else}
migrate.run()}
>
- {migrate.error ? "Try again" : "Migrate my data"}
+ {migrate.error ? "Try again" : "Start migration"}
{/if}
(confirmSkip = true)}
>
Skip migration
- Sign out
+
+ Sign out
+
+
+ {#if status}
+
+ {/if}
migrate.run(true)}
/>
diff --git a/web/src/lib/migration/import.ts b/web/src/lib/migration/import.ts
index ff99dc6fd..4aadd01e3 100644
--- a/web/src/lib/migration/import.ts
+++ b/web/src/lib/migration/import.ts
@@ -28,6 +28,7 @@ export interface ImportProgress {
phase: "reading" | "blobs" | "importing" | "finalizing";
done: number;
total: number;
+ overall: { done: number; total: number };
}
export class MigrationScopeError extends Error {
@@ -168,7 +169,7 @@ export const importFromLiar = async (
);
}
- onProgress?.({ phase: "reading", done: 0, total: 0 });
+ onProgress?.({ phase: "reading", done: 0, total: 0, overall: { done: 0, total: 0 } });
const records = await readLiarRecords(
await fetchLiarRepo(liarPdsUrl, agent.sub, { fetch, signal })
);
@@ -184,22 +185,29 @@ export const importFromLiar = async (
const client = createClient(agent);
const blobs = await listLiarBlobs(liarPdsUrl, agent.sub, { fetch, signal });
- onProgress?.({ phase: "blobs", done: 0, total: blobs.length });
+ const batches = batchWrites(writes);
+ const overall = { done: 0, total: blobs.length + batches.length };
+ const report = (phase: "blobs" | "importing", done: number, total: number) =>
+ onProgress?.({ phase, done, total, overall: { ...overall } });
+
+ report("blobs", 0, blobs.length);
for (const [i, cid] of blobs.entries()) {
const input = await fetchLiarBlob(liarPdsUrl, agent.sub, cid, { fetch, signal });
await ok(client.call(uploadBlobSchema, { input, signal }));
- onProgress?.({ phase: "blobs", done: i + 1, total: blobs.length });
+ overall.done++;
+ report("blobs", i + 1, blobs.length);
}
let done = 0;
- onProgress?.({ phase: "importing", done, total: writes.length });
- for (const batch of batchWrites(writes)) {
+ report("importing", done, writes.length);
+ for (const batch of batches) {
signal?.throwIfAborted();
await ok(
client.call(applyWritesSchema, { input: { repo: agent.sub, writes: batch }, signal })
);
done += batch.length;
- onProgress?.({ phase: "importing", done, total: writes.length });
+ overall.done++;
+ report("importing", done, writes.length);
}
clear();