fix the remove index tool not calling the snapshot problem

Signed-off-by: ChengZi <chen.zhang@zilliz.com>
This commit is contained in:
ChengZi
2025-08-21 11:34:18 +08:00
committed by Cheney Zhang
parent 2605d09c44
commit 8a63f729e9
2 changed files with 42 additions and 3 deletions

View File

@@ -638,9 +638,8 @@ export class ToolHandlers {
};
}
// Remove the cleared codebase from both lists
this.snapshotManager.removeIndexedCodebase(absolutePath);
this.snapshotManager.removeIndexingCodebase(absolutePath);
// Completely remove the cleared codebase from snapshot
this.snapshotManager.removeCodebaseCompletely(absolutePath);
// Reset indexing stats if this was the active codebase
this.indexingStats = null;

View File

@@ -178,6 +178,9 @@ export class SnapshotManager {
}
}
/**
* @deprecated Use getCodebaseInfo() for individual codebases or iterate through codebases for v2 format support
*/
public getIndexingCodebasesWithProgress(): Map<string, number> {
return new Map(this.indexingCodebases);
}
@@ -217,20 +220,32 @@ export class SnapshotManager {
}
}
/**
* @deprecated Use setCodebaseIndexing() instead for v2 format support
*/
public addIndexingCodebase(codebasePath: string, progress: number = 0): void {
this.indexingCodebases.set(codebasePath, progress);
}
/**
* @deprecated Use setCodebaseIndexing() instead for v2 format support
*/
public updateIndexingProgress(codebasePath: string, progress: number): void {
if (this.indexingCodebases.has(codebasePath)) {
this.indexingCodebases.set(codebasePath, progress);
}
}
/**
* @deprecated Use removeCodebaseCompletely() or state-specific methods instead for v2 format support
*/
public removeIndexingCodebase(codebasePath: string): void {
this.indexingCodebases.delete(codebasePath);
}
/**
* @deprecated Use setCodebaseIndexed() instead for v2 format support
*/
public addIndexedCodebase(codebasePath: string, fileCount?: number): void {
if (!this.indexedCodebases.includes(codebasePath)) {
this.indexedCodebases.push(codebasePath);
@@ -240,20 +255,32 @@ export class SnapshotManager {
}
}
/**
* @deprecated Use removeCodebaseCompletely() or state-specific methods instead for v2 format support
*/
public removeIndexedCodebase(codebasePath: string): void {
this.indexedCodebases = this.indexedCodebases.filter(path => path !== codebasePath);
this.codebaseFileCount.delete(codebasePath);
}
/**
* @deprecated Use setCodebaseIndexed() instead for v2 format support
*/
public moveFromIndexingToIndexed(codebasePath: string, fileCount?: number): void {
this.removeIndexingCodebase(codebasePath);
this.addIndexedCodebase(codebasePath, fileCount);
}
/**
* @deprecated Use getCodebaseInfo() and check indexedFiles property instead for v2 format support
*/
public getIndexedFileCount(codebasePath: string): number | undefined {
return this.codebaseFileCount.get(codebasePath);
}
/**
* @deprecated Use setCodebaseIndexed() with complete stats instead for v2 format support
*/
public setIndexedFileCount(codebasePath: string, fileCount: number): void {
this.codebaseFileCount.set(codebasePath, fileCount);
}
@@ -353,6 +380,19 @@ export class SnapshotManager {
.map(([path, _]) => path);
}
/**
* Completely remove a codebase from all tracking (for clear_index operation)
*/
public removeCodebaseCompletely(codebasePath: string): void {
// Remove from all internal state
this.indexedCodebases = this.indexedCodebases.filter(path => path !== codebasePath);
this.indexingCodebases.delete(codebasePath);
this.codebaseFileCount.delete(codebasePath);
this.codebaseInfoMap.delete(codebasePath);
console.log(`[SNAPSHOT-DEBUG] Completely removed codebase from snapshot: ${codebasePath}`);
}
public loadCodebaseSnapshot(): void {
console.log('[SNAPSHOT-DEBUG] Loading codebase snapshot from:', this.snapshotFilePath);