From aad532bfddd31a217cb27e971855d3b9f7ae1734 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Fri, 23 Jan 2026 04:32:03 +0100 Subject: [PATCH] fix(sync): hotfix for the initial race condition for books sync (#3038) --- apps/readest-app/src/pages/api/sync.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/readest-app/src/pages/api/sync.ts b/apps/readest-app/src/pages/api/sync.ts index 94110678..b9bb908d 100644 --- a/apps/readest-app/src/pages/api/sync.ts +++ b/apps/readest-app/src/pages/api/sync.ts @@ -118,6 +118,26 @@ export async function GET(req: NextRequest) { if (!typeParam || typeParam === 'books') { await queryTables('books').catch((err) => (errors['books'] = err)); + // TODO: Remove this hotfix for the initial race condition for books sync + if (results.books?.length === 0 && since.getTime() < 1000) { + const dummyHash = '00000000000000000000000000000000'; + const now = new Date().getTime(); + results.books.push({ + user_id: user.id, + id: dummyHash, + book_hash: dummyHash, + deleted_at: now, + updated_at: now, + + hash: dummyHash, + title: 'Dummy Book', + format: 'EPUB', + author: '', + createdAt: now, + updatedAt: now, + deletedAt: now, + }); + } } if (!typeParam || typeParam === 'configs') { await queryTables('book_configs').catch((err) => (errors['book_configs'] = err));