Fix backup restore dropping library entries (#3667)
* Fix backup restore dropping library entries History restore resolved chapters by URL alone, so a backup holding the same entry twice under one source matched multiple chapter rows and threw `ResultSet returned more than 1 row`. Scope the lookups to the entry. Entries are restored in chunks of 100 sharing one transaction. SQLDelight fails the enclosing transaction when a nested one fails, so catching the per-entry exception did not contain it and the whole chunk rolled back, losing up to 100 entries per bad one. Retry entry by entry on failure. Refs #647 * Update changelog --------- Co-authored-by: Naji Astier <na-ji@users.noreply.github.com>
This commit is contained in:
@@ -88,7 +88,8 @@ getChapterByUrlAndMangaId:
|
||||
SELECT *
|
||||
FROM chapters
|
||||
WHERE url = :chapterUrl
|
||||
AND manga_id = :mangaId;
|
||||
AND manga_id = :mangaId
|
||||
LIMIT 1;
|
||||
|
||||
removeChaptersWithIds:
|
||||
DELETE FROM chapters
|
||||
|
||||
@@ -23,7 +23,7 @@ JOIN chapters C
|
||||
ON H.chapter_id = C._id
|
||||
WHERE C.manga_id = :mangaId AND C._id = H.chapter_id;
|
||||
|
||||
getHistoryByChapterUrl:
|
||||
getHistoryByChapterUrlAndMangaId:
|
||||
SELECT
|
||||
H._id,
|
||||
H.chapter_id,
|
||||
@@ -32,7 +32,8 @@ H.time_read
|
||||
FROM history H
|
||||
JOIN chapters C
|
||||
ON H.chapter_id = C._id
|
||||
WHERE C.url = :chapterUrl AND C._id = H.chapter_id;
|
||||
WHERE C.url = :chapterUrl AND C.manga_id = :mangaId AND C._id = H.chapter_id
|
||||
LIMIT 1;
|
||||
|
||||
resetHistoryById:
|
||||
UPDATE history
|
||||
|
||||
Reference in New Issue
Block a user