Abort active migration search on manual search match selection

This commit is contained in:
schroda
2026-05-16 22:37:23 +02:00
parent 531ec46be7
commit cd8fde4a7b
2 changed files with 17 additions and 5 deletions

View File

@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- (**Migration**) Sort destination source selection by same order as browse source page - (**Migration**) Sort destination source selection by same order as browse source page
- (**Migration**) Sort entries in search/execution page by title - (**Migration**) Sort entries in search/execution page by title
- (**Migration**) Prevent a manual selected match from getting automatically overwritten by a new-found match - (**Migration**) Prevent a manual selected match from getting automatically overwritten by a new-found match
- (**Migration**) Abort active search when selecting a match through the manual search
### Fixed ### Fixed

View File

@@ -97,7 +97,8 @@ export class MigrationManager {
private static mangaProcessQueue = pLimit(MAX_MANGAS_IN_PARALLEL); private static mangaProcessQueue = pLimit(MAX_MANGAS_IN_PARALLEL);
private static parallelSourcesQueue: LimitFunction | undefined; private static parallelSourcesQueue: LimitFunction | undefined;
private static queueBySource = new Map<string, LimitFunction>(); private static queueBySource = new Map<SourceIdInfo['id'], LimitFunction>();
private static searchAbortControllerByManga = new Map<MangaIdInfo['id'], AbortController>();
private static abortAndResetAbortController(reason: unknown): void { private static abortAndResetAbortController(reason: unknown): void {
MigrationManager.abortController?.abort(reason); MigrationManager.abortController?.abort(reason);
@@ -617,7 +618,16 @@ export class MigrationManager {
draft.entries[mangaId].manualMatches = [...draft.entries[mangaId].manualMatches, match]; draft.entries[mangaId].manualMatches = [...draft.entries[mangaId].manualMatches, match];
} }
const isSearching = ![
MigrationEntryStatus.SEARCH_FAILED,
MigrationEntryStatus.SEARCH_COMPLETE,
].includes(entry.status);
MigrationManager.selectMatch(mangaId, match.id, match.sourceId, true); MigrationManager.selectMatch(mangaId, match.id, match.sourceId, true);
if (isSearching) {
MigrationManager.searchAbortControllerByManga.get(mangaId)?.abort('Manual match selected');
}
} }
}); });
} }
@@ -705,10 +715,6 @@ export class MigrationManager {
throw new Error(signal.reason); throw new Error(signal.reason);
} }
if (signal.aborted) {
throw new Error(signal.reason);
}
if (!selectHighestChapterNumberSource && MigrationManager.hasHigherSourcePriorityMatch(mangaId, sourceId)) { if (!selectHighestChapterNumberSource && MigrationManager.hasHigherSourcePriorityMatch(mangaId, sourceId)) {
throw new Error('Entry already has a selected match from a higher priority source'); throw new Error('Entry already has a selected match from a higher priority source');
} }
@@ -803,6 +809,9 @@ export class MigrationManager {
const searchController = new AbortController(); const searchController = new AbortController();
const signal = AbortSignal.any([mainSignal, searchController.signal]); const signal = AbortSignal.any([mainSignal, searchController.signal]);
MigrationManager.searchAbortControllerByManga.get(mangaId)?.abort('search');
MigrationManager.searchAbortControllerByManga.set(mangaId, searchController);
if (!entry) { if (!entry) {
return; return;
} }
@@ -973,6 +982,8 @@ export class MigrationManager {
draft.searchProgress.completed += 1; draft.searchProgress.completed += 1;
draft.searchProgress.failed += 1; draft.searchProgress.failed += 1;
}); });
} finally {
MigrationManager.searchAbortControllerByManga.delete(mangaId);
} }
} }