From 526a0884bd602494fab820d42a619e5f6e6c9655 Mon Sep 17 00:00:00 2001 From: uy_sun Date: Thu, 1 Feb 2024 12:57:31 +0800 Subject: [PATCH] fix: update only when info changed --- src/services/updates/LibraryUpdateQueries.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/services/updates/LibraryUpdateQueries.ts b/src/services/updates/LibraryUpdateQueries.ts index 37731d46fc..7c5a390905 100644 --- a/src/services/updates/LibraryUpdateQueries.ts +++ b/src/services/updates/LibraryUpdateQueries.ts @@ -67,7 +67,16 @@ const updateNovel = async ( novel.chapters?.forEach(chapter => { const { name, url, releaseTime } = chapter; tx.executeSql( - "INSERT INTO Chapter (url, name, releaseTime, novelId, updatedTime) values (?, ?, ?, ?, datetime('now','localtime')) ON CONFLICT(url) DO UPDATE SET name=excluded.name, releaseTime=excluded.releaseTime, novelId=excluded.novelId, updatedTime=excluded.updatedTime", + ` + INSERT INTO Chapter (url, name, releaseTime, novelId, updatedTime) + VALUES (?, ?, ?, ?, datetime('now','localtime')) + ON CONFLICT(url) DO UPDATE SET + name=excluded.name, + releaseTime=excluded.releaseTime, + updatedTime=excluded.updatedTime + WHERE Chapter.name != excluded.name + OR Chapter.releaseTime != excluded.releaseTime; + `, [url, name, releaseTime || '', novelId], (txObj, { insertId }) => { if (insertId && downloadNewChapters) {