From f7b6006cc0862dcd956593e285827677743adc60 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Thu, 6 Mar 2025 21:09:07 +0100 Subject: [PATCH] Delete chapters on migration again Regression a29c113b5f23b556b186178441890514aa9fc359 --- src/modules/manga/services/Mangas.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/modules/manga/services/Mangas.ts b/src/modules/manga/services/Mangas.ts index 4601cb1f..45838c2b 100644 --- a/src/modules/manga/services/Mangas.ts +++ b/src/modules/manga/services/Mangas.ts @@ -285,6 +285,7 @@ export class Mangas { mode: MigrateMode, mangaToMigrate: GetMangaToMigrateQuery['manga'], mangaToMigrateToInfo: GetMangaToMigrateToFetchMutation, + deleteChapters: boolean, ): MigrateFuncReturn { if (!mangaToMigrate.chapters || !mangaToMigrateToInfo.fetchChapters?.chapters) { throw new Error('Chapters are missing'); @@ -320,9 +321,11 @@ export class Mangas { cleanup: () => mode === 'migrate' ? [ - requestManager.deleteDownloadedChapters( - Chapters.getIds(Chapters.getDownloaded(mangaToMigrate.chapters?.nodes ?? [])), - ).response, + deleteChapters + ? requestManager.deleteDownloadedChapters( + Chapters.getIds(Chapters.getDownloaded(mangaToMigrate.chapters?.nodes ?? [])), + ).response + : Promise.resolve(), ] : [], }; @@ -461,7 +464,10 @@ export class Mangas { }; await performMigrationActions( - [migrateChapters, Mangas.migrateChapters(mode, mangaToMigrateData.manga, mangaToMigrateToData)], + [ + migrateChapters, + Mangas.migrateChapters(mode, mangaToMigrateData.manga, mangaToMigrateToData, !!deleteChapters), + ], [ migrateTracking, Mangas.migrateTracking(mode, mangaToMigrateData.manga, mangaToMigrateToData.fetchManga.manga),