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:
@@ -74,6 +74,7 @@ import { AppSession } from '@/base/AppSession.ts';
|
||||
import { ControlledPromise } from '@/lib/ControlledPromise.ts';
|
||||
import { d } from 'koration';
|
||||
import merge from 'lodash/fp/merge';
|
||||
import mapValues from 'lodash/fp/mapValues';
|
||||
|
||||
const RESUMABLE_PHASES: readonly MigrationPhase[] = [MigrationPhase.SEARCHING, MigrationPhase.MIGRATING];
|
||||
|
||||
@@ -912,7 +913,17 @@ export class MigrationManager {
|
||||
MigrationManager.abortControllerByManga.set(mangaId, searchController);
|
||||
|
||||
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 {
|
||||
@@ -1117,7 +1128,10 @@ export class MigrationManager {
|
||||
MigrationManager.abortControllerByManga.set(mangaId, migrateController);
|
||||
|
||||
MigrationManager.updateState((draft) => {
|
||||
draft.entries[mangaId].status = MigrationEntryStatus.MIGRATING;
|
||||
const draftEntry = draft.entries[mangaId];
|
||||
|
||||
draftEntry.status = MigrationEntryStatus.MIGRATING;
|
||||
draftEntry.error = undefined;
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -1178,9 +1192,7 @@ export class MigrationManager {
|
||||
|
||||
if (MigrationEntries.hasStatus(entry, MigrationEntryStatus.SEARCH_FAILED)) {
|
||||
MigrationManager.updateState((draft) => {
|
||||
const draftEntry = draft.entries[id];
|
||||
draftEntry.status = MigrationEntryStatus.SEARCH_PENDING;
|
||||
draftEntry.error = undefined;
|
||||
draft.entries[id].status = MigrationEntryStatus.SEARCH_PENDING;
|
||||
});
|
||||
|
||||
assertIsDefined(searchOptions);
|
||||
@@ -1194,9 +1206,7 @@ export class MigrationManager {
|
||||
|
||||
if (MigrationEntries.hasStatus(entry, MigrationEntryStatus.MIGRATION_FAILED)) {
|
||||
MigrationManager.updateState((draft) => {
|
||||
const draftEntry = draft.entries[id];
|
||||
draftEntry.status = MigrationEntryStatus.MIGRATION_PENDING;
|
||||
draftEntry.error = undefined;
|
||||
draft.entries[id].status = MigrationEntryStatus.MIGRATION_PENDING;
|
||||
});
|
||||
|
||||
assertIsDefined(migrateOptions);
|
||||
|
||||
Reference in New Issue
Block a user