From 782148a10e3dae9bc6166eff0b54fe670c64eb39 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:40:55 +0200 Subject: [PATCH] Handle target manga without chapters on migration The server throws an error in case the source returns an empty chapter list. However, this is not an error and should not break/stop the migration --- src/lib/data/Mangas.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/data/Mangas.ts b/src/lib/data/Mangas.ts index 91ad953c..2ece0b87 100644 --- a/src/lib/data/Mangas.ts +++ b/src/lib/data/Mangas.ts @@ -506,6 +506,7 @@ export class Mangas { migrateChapters, migrateCategories, migrateTracking, + apolloOptions: { errorPolicy: 'all' }, }).response, getMetadataServerSettings(), ]); @@ -514,13 +515,14 @@ export class Mangas { throw new Error('Mangas::migrate: missing manga data'); } - if ( - migrateChapters && - (!mangaToMigrateData.manga.chapters || !mangaToMigrateToData.fetchChapters?.chapters) - ) { + if (migrateChapters && !mangaToMigrateData.manga.chapters) { throw new Error('Mangas::migrate: missing chapters data'); } + if (!mangaToMigrateToData.fetchChapters?.chapters) { + mangaToMigrateToData.fetchChapters = { chapters: [] }; + } + const performMigrationAction = async ( migrateAction: keyof MigrateFuncReturn, ...actions: [boolean | undefined, MigrateFuncReturn][]