From 47a952cd0db7ab9d9c24f33087bab37002efd8d0 Mon Sep 17 00:00:00 2001 From: ashwin271 Date: Mon, 17 Feb 2025 07:40:49 +0530 Subject: [PATCH] Remove manual file tracking in favor of Obsidian API - Remove lastUpdated and checksum from VectorData interface - Remove calculateChecksum method - Update buildVectorIndex to remove redundant tracking - Prepare for Obsidian's built-in file tracking system --- main.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/main.ts b/main.ts index 84f290d..36c2301 100644 --- a/main.ts +++ b/main.ts @@ -13,8 +13,6 @@ import { interface VectorData { path: string; embedding: number[]; - lastUpdated: number; - checksum: string; title: string; startLine: number; endLine: number; @@ -89,15 +87,6 @@ export default class VectorSearchPlugin extends Plugin { ); } - // Helper function to calculate checksum - private calculateChecksum(content: string): string { - // Simple implementation - you might want to use a proper hashing library - return content.split('').reduce((a, b) => { - a = ((a << 5) - a) + b.charCodeAt(0); - return a & a; - }, 0).toString(); - } - async saveSettings() { await this.saveData(this.settings); } @@ -272,8 +261,6 @@ export default class VectorSearchPlugin extends Plugin { const vectorData: VectorData = { path: normalizePath(file.path), embedding: embedding, - lastUpdated: Date.now(), - checksum: this.calculateChecksum(chunk), title: `${file.basename} (chunk ${i + 1}/${chunks.length})`, startLine, endLine @@ -288,7 +275,7 @@ export default class VectorSearchPlugin extends Plugin { `Indexing files: ${processed}/${total} (${Math.round((processed / total) * 100)}%)` ); } - + this.settings.vectors = Array.from(this.vectorStore.values()); await this.saveSettings();