@akiojin/unity-mcp-server 2.45.3 → 2.45.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/core/codeIndex.js
CHANGED
|
@@ -72,8 +72,17 @@ export class CodeIndex {
|
|
|
72
72
|
|
|
73
73
|
// Use shared connection for all CodeIndex instances
|
|
74
74
|
if (sharedConnections.db && sharedConnections.dbPath === dbPath) {
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
// Verify the DB file still exists before returning cached connection
|
|
76
|
+
if (!fs.existsSync(dbPath)) {
|
|
77
|
+
// File was deleted or never created, invalidate cache
|
|
78
|
+
logger.info('[index] DB file missing, invalidating cached connection');
|
|
79
|
+
sharedConnections.db = null;
|
|
80
|
+
sharedConnections.dbPath = null;
|
|
81
|
+
sharedConnections.schemaInitialized = false;
|
|
82
|
+
} else {
|
|
83
|
+
this.db = sharedConnections.db;
|
|
84
|
+
return this.db;
|
|
85
|
+
}
|
|
77
86
|
}
|
|
78
87
|
|
|
79
88
|
try {
|
|
@@ -31,9 +31,24 @@ function saveDatabase(db, dbPath) {
|
|
|
31
31
|
try {
|
|
32
32
|
const data = db.exportDb();
|
|
33
33
|
const buffer = Buffer.from(data);
|
|
34
|
+
|
|
35
|
+
// Ensure parent directory exists
|
|
36
|
+
const dir = path.dirname(dbPath);
|
|
37
|
+
if (!fs.existsSync(dir)) {
|
|
38
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
fs.writeFileSync(dbPath, buffer);
|
|
42
|
+
|
|
43
|
+
// Verify file was written
|
|
44
|
+
if (!fs.existsSync(dbPath)) {
|
|
45
|
+
throw new Error('Database file was not created');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
log('info', `[worker] Database saved successfully: ${dbPath} (${buffer.length} bytes)`);
|
|
35
49
|
} catch (e) {
|
|
36
|
-
log('
|
|
50
|
+
log('error', `[worker] Failed to save database: ${e.message}`);
|
|
51
|
+
throw e; // Re-throw to fail the build
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
|