Skip to content

Commit 654fe56

Browse files
bealqiuclaude
andcommitted
fix(sync): exclude soft-deleted books from file sync
The books query in syncFiles was not filtering out soft-deleted records (deleted_at IS NOT NULL), so deleted books remained in currentBookIds and their remote files were never cleaned up. On next sync the remote snapshot would re-create the book record, effectively un-deleting it. Add WHERE deleted_at IS NULL to the query so remote files for deleted books are properly cleaned up during sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7ceae06 commit 654fe56

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/core/src/sync/sync-files.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ export async function syncFiles(
7272
let filesUploaded = 0;
7373
let filesDownloaded = 0;
7474

75-
// Get all books from DB
75+
// Get all books from DB (exclude soft-deleted books)
7676
const books = await db.select<{
7777
id: string;
7878
file_path: string;
7979
file_hash: string;
8080
cover_url: string;
8181
title: string;
82-
}>("SELECT id, file_path, file_hash, cover_url, title FROM books", []);
82+
}>("SELECT id, file_path, file_hash, cover_url, title FROM books WHERE deleted_at IS NULL", []);
8383

8484
const appDataDir = await adapter.getAppDataDir();
8585
const currentBookIds = new Set(books.map((book) => book.id));

0 commit comments

Comments
 (0)