Skip to content

Commit 49a3c1f

Browse files
committed
fix: resolve store path correctly when not in project root
- Use import.meta.dirname for proper path resolution - Handle store path resolution priority: env var > legacy path > standard path - Ensure database directory exists before initialization
1 parent b48fb3c commit 49a3c1f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/store/DocumentManagementService.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ describe("DocumentManagementService", () => {
5959
let docService: DocumentManagementService; // For general tests
6060

6161
// Define expected paths consistently
62-
const expectedOldDbPath = path.join(process.cwd(), ".store", "documents.db");
62+
const projectRoot = path.resolve(import.meta.dirname, "..");
63+
const expectedOldDbPath = path.join(projectRoot, ".store", "documents.db");
6364
const expectedStandardDbPath = path.join(mockEnvPaths.data, "documents.db");
6465

6566
beforeEach(() => {

src/store/DocumentManagementService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export class DocumentManagementService {
4141
logger.debug(`💾 Using database directory from DOCS_MCP_STORE_PATH: ${dbDir}`);
4242
} else {
4343
// 2. Check Old Local Path
44-
const oldDbDir = path.join(process.cwd(), ".store");
44+
const projectRoot = path.resolve(import.meta.dirname, "..");
45+
const oldDbDir = path.join(projectRoot, ".store");
46+
console.log("Old DB Directory:", oldDbDir);
4547
const oldDbPath = path.join(oldDbDir, "documents.db");
4648
const oldDbExists = existsSync(oldDbPath); // Check file existence specifically
4749

0 commit comments

Comments
 (0)