diff --git a/electron/main/vector-database/lanceTableWrapper.ts b/electron/main/vector-database/lanceTableWrapper.ts index d16833e1..5b710c4e 100644 --- a/electron/main/vector-database/lanceTableWrapper.ts +++ b/electron/main/vector-database/lanceTableWrapper.ts @@ -45,7 +45,7 @@ class LanceDBTableWrapper { await this.deleteDBItemsByFilePaths(data.map((x) => x.notepath)) const recordEntry: Record[] = data as unknown as Record[] - const numberOfChunksToIndexAtOnce = 50 + const numberOfChunksToIndexAtOnce = process.platform === 'darwin' ? 50 : 40 const chunks = [] for (let i = 0; i < recordEntry.length; i += numberOfChunksToIndexAtOnce) { chunks.push(recordEntry.slice(i, i + numberOfChunksToIndexAtOnce)) @@ -54,15 +54,16 @@ class LanceDBTableWrapper { if (chunks.length === 0) return const totalChunks = chunks.length - chunks.forEach(async (chunk, index) => { + + await chunks.reduce(async (previousPromise, chunk, index) => { + await previousPromise const arrowTableOfChunk = makeArrowTable(chunk) await this.lanceTable.add(arrowTableOfChunk) - const progress = (index + 1) / totalChunks if (onProgress) { onProgress(progress) } - }) + }, Promise.resolve()) } async deleteDBItemsByFilePaths(filePaths: string[]): Promise { diff --git a/electron/main/vector-database/tableHelperFunctions.ts b/electron/main/vector-database/tableHelperFunctions.ts index e37b170b..26b1c637 100644 --- a/electron/main/vector-database/tableHelperFunctions.ts +++ b/electron/main/vector-database/tableHelperFunctions.ts @@ -146,9 +146,6 @@ export const RepopulateTableWithMissingItems = async ( return } - const filePathsToDelete = dbItemsToAdd.map((x) => x[0].notepath) - await table.deleteDBItemsByFilePaths(filePathsToDelete) - const flattenedItemsToAdd = dbItemsToAdd.flat() await table.add(flattenedItemsToAdd, onProgress) diff --git a/package-lock.json b/package-lock.json index 44aa8b60..79a5a56a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "reor-project", - "version": "0.2.19", + "version": "0.2.21", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "reor-project", - "version": "0.2.19", + "version": "0.2.21", "license": "AGPL-3.0", "dependencies": { "@aarkue/tiptap-math-extension": "^1.2.2",