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
This commit is contained in:
schroda
2024-08-14 14:40:55 +02:00
parent d14255494d
commit 782148a10e

View File

@@ -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][]