Use stable manga and chapter composite keys for sync matching (#2124)

This commit is contained in:
Bartu Özen
2026-06-27 20:41:14 +03:00
committed by GitHub
parent 656d86c6f6
commit b6de3c3e39

View File

@@ -305,8 +305,7 @@ object SyncYomiSyncService {
logger.debug { "Starting merge. Local list size: ${localMangaListSafe.size}, Remote list size: ${remoteMangaListSafe.size}" } logger.debug { "Starting merge. Local list size: ${localMangaListSafe.size}, Remote list size: ${remoteMangaListSafe.size}" }
fun mangaCompositeKey(manga: BackupManga): String = fun mangaCompositeKey(manga: BackupManga): String = "${manga.source}|${manga.url}"
"${manga.source}|${manga.url}|${manga.title.lowercase().trim()}|${manga.author?.lowercase()?.trim()}"
// Create maps using composite keys // Create maps using composite keys
val localMangaMap = localMangaListSafe.associateBy { mangaCompositeKey(it) } val localMangaMap = localMangaListSafe.associateBy { mangaCompositeKey(it) }
@@ -415,7 +414,7 @@ object SyncYomiSyncService {
return remoteChapters // If not syncing chapters, keep remote untouched return remoteChapters // If not syncing chapters, keep remote untouched
} }
fun chapterCompositeKey(chapter: BackupChapter): String = "${chapter.url}|${chapter.name}|${chapter.chapterNumber}" fun chapterCompositeKey(chapter: BackupChapter): String = chapter.url
val localChapterMap = localChapters.associateBy { chapterCompositeKey(it) } val localChapterMap = localChapters.associateBy { chapterCompositeKey(it) }
val remoteChapterMap = remoteChapters.associateBy { chapterCompositeKey(it) } val remoteChapterMap = remoteChapters.associateBy { chapterCompositeKey(it) }