feat(learn): an archive's import shows its steps, counts and percent, with Abort

Importing a Halkyon archive showed one bar. It now says which of its three
steps it is in (copying files; writing studysets, flashcards and notes;
bringing over the progress), how many of the step's items are done and the
percent of all of it, and offers Abort (decided 9 Nov 2026).

The copier checks between items, never leaving one half written, and
keeps a trail of what it wrote: the top studyset once made, and the files'
rows it made (not those the person had, found before each file is added).
Aborted, the importer deletes the top studyset for good with everything
inside it, as Delete now does (the reviews, answers and pages read going
with their cards, steps and PDFs), and those rows; the tags it made stay,
as names the person may well use anyway. Once all of it is written, Abort
no longer undoes it.

WorkProgress, WorkStages and AbortSignal (core/work/) and
WorkProgressView (core/widget/) are shared with the Anki import and the
exports, which follow.

Whats-New: Importing an archive shows its steps and how far it has come, and Abort stops it, keeping nothing of it.
Whats-New-De: Der Import eines Archivs zeigt seine Schritte und wie weit er ist, und „Abbrechen“ beendet ihn, ohne etwas davon zu behalten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-11-10 15:53:31 +01:00
commit 5f7cb70c3c
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -38,6 +38,9 @@ class FakeCardGateway() implements CardGateway {
/// When set, deleting a card waits until it completes.
Completer<void>? holdDeletes;
/// When set, storing cards in a batch waits until it completes.
Completer<void>? holdWrites;
/// The payload each revision holds now, by revision id.
Map<String, ByteData> get payloads => {
for (final revision in _revisions.values) revision.id: revision.payload,
@ -86,14 +89,19 @@ class FakeCardGateway() implements CardGateway {
Future<List<String>> insertCards(
String studysetId,
List<NewCardRow> cards,
) async => [
for (final card in cards)
await insertCard(
studysetId: studysetId,
position: card.position,
payload: card.payload,
),
];
) async {
if (holdWrites case final hold?) {
await hold.future;
}
return [
for (final card in cards)
await insertCard(
studysetId: studysetId,
position: card.position,
payload: card.payload,
),
];
}
@override
Future<String> insertCard({