Reset search/migration state on retry

When resuming a migration search, it was possible that an entry search was partially done.
In this case, when retrying, the sources with search results were not retried.
If all retried source searches failed, it was incorrectly treated as if all source searches failed, since it only considers the actually executed search sources, which only included failed/pending sources.
This commit is contained in:
schroda
2026-06-21 13:17:13 +02:00
parent 675c7284e5
commit 6015b7a84b
2 changed files with 19 additions and 8 deletions

View File

@@ -54,6 +54,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- (**Migration**) Fix selecting a destination from a source browse search page - (**Migration**) Fix selecting a destination from a source browse search page
- (**Migration**) Fix being able to migrate an entry to itself - (**Migration**) Fix being able to migrate an entry to itself
- (**Migration**) Fix resuming migration when app is opened in multiple tabs - (**Migration**) Fix resuming migration when app is opened in multiple tabs
- (**Migration**) Fix showing "All source searches failed" error while the entry has a selected destination source or matches were found
- (**Reader**) Fix scrollbar appearing with "fit to widt/height/screen" page scale mode and applied safe area insets - (**Reader**) Fix scrollbar appearing with "fit to widt/height/screen" page scale mode and applied safe area insets
- (**Reader**) Fix wrongly positioned mobile progress bar current page indicator - (**Reader**) Fix wrongly positioned mobile progress bar current page indicator
- (**Reader**) Fix mobile progress bar previous/next chapter button visibility on hover and while disabled - (**Reader**) Fix mobile progress bar previous/next chapter button visibility on hover and while disabled

View File

@@ -74,6 +74,7 @@ import { AppSession } from '@/base/AppSession.ts';
import { ControlledPromise } from '@/lib/ControlledPromise.ts'; import { ControlledPromise } from '@/lib/ControlledPromise.ts';
import { d } from 'koration'; import { d } from 'koration';
import merge from 'lodash/fp/merge'; import merge from 'lodash/fp/merge';
import mapValues from 'lodash/fp/mapValues';
const RESUMABLE_PHASES: readonly MigrationPhase[] = [MigrationPhase.SEARCHING, MigrationPhase.MIGRATING]; const RESUMABLE_PHASES: readonly MigrationPhase[] = [MigrationPhase.SEARCHING, MigrationPhase.MIGRATING];
@@ -912,7 +913,17 @@ export class MigrationManager {
MigrationManager.abortControllerByManga.set(mangaId, searchController); MigrationManager.abortControllerByManga.set(mangaId, searchController);
MigrationManager.updateState((draft) => { MigrationManager.updateState((draft) => {
draft.entries[mangaId].status = MigrationEntryStatus.SEARCHING; const draftEntry = draft.entries[mangaId];
draftEntry.status = MigrationEntryStatus.SEARCHING;
draftEntry.error = undefined;
draftEntry.searchMatches = [];
draftEntry.manualMatches = [];
draftEntry.isManualSelection = false;
draftEntry.selectedMatchMangaId = null;
draftEntry.selectedMatchSourceId = null;
draftEntry.areMatchesExpanded = false;
draftEntry.destSourceIdToSearchState = mapValues(() => false, draftEntry.destSourceIdToSearchState);
}); });
try { try {
@@ -1117,7 +1128,10 @@ export class MigrationManager {
MigrationManager.abortControllerByManga.set(mangaId, migrateController); MigrationManager.abortControllerByManga.set(mangaId, migrateController);
MigrationManager.updateState((draft) => { MigrationManager.updateState((draft) => {
draft.entries[mangaId].status = MigrationEntryStatus.MIGRATING; const draftEntry = draft.entries[mangaId];
draftEntry.status = MigrationEntryStatus.MIGRATING;
draftEntry.error = undefined;
}); });
try { try {
@@ -1178,9 +1192,7 @@ export class MigrationManager {
if (MigrationEntries.hasStatus(entry, MigrationEntryStatus.SEARCH_FAILED)) { if (MigrationEntries.hasStatus(entry, MigrationEntryStatus.SEARCH_FAILED)) {
MigrationManager.updateState((draft) => { MigrationManager.updateState((draft) => {
const draftEntry = draft.entries[id]; draft.entries[id].status = MigrationEntryStatus.SEARCH_PENDING;
draftEntry.status = MigrationEntryStatus.SEARCH_PENDING;
draftEntry.error = undefined;
}); });
assertIsDefined(searchOptions); assertIsDefined(searchOptions);
@@ -1194,9 +1206,7 @@ export class MigrationManager {
if (MigrationEntries.hasStatus(entry, MigrationEntryStatus.MIGRATION_FAILED)) { if (MigrationEntries.hasStatus(entry, MigrationEntryStatus.MIGRATION_FAILED)) {
MigrationManager.updateState((draft) => { MigrationManager.updateState((draft) => {
const draftEntry = draft.entries[id]; draft.entries[id].status = MigrationEntryStatus.MIGRATION_PENDING;
draftEntry.status = MigrationEntryStatus.MIGRATION_PENDING;
draftEntry.error = undefined;
}); });
assertIsDefined(migrateOptions); assertIsDefined(migrateOptions);