magector 2.1.4 → 2.1.5

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/mcp-server.js +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magector",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "Semantic code search for Magento 2 — index, search, MCP server",
5
5
  "type": "module",
6
6
  "main": "src/mcp-server.js",
@@ -39,10 +39,10 @@
39
39
  "ruvector": "^0.1.96"
40
40
  },
41
41
  "optionalDependencies": {
42
- "@magector/cli-darwin-arm64": "2.1.4",
43
- "@magector/cli-linux-x64": "2.1.4",
44
- "@magector/cli-linux-arm64": "2.1.4",
45
- "@magector/cli-win32-x64": "2.1.4"
42
+ "@magector/cli-darwin-arm64": "2.1.5",
43
+ "@magector/cli-linux-x64": "2.1.5",
44
+ "@magector/cli-linux-arm64": "2.1.5",
45
+ "@magector/cli-win32-x64": "2.1.5"
46
46
  },
47
47
  "keywords": [
48
48
  "magento",
package/src/mcp-server.js CHANGED
@@ -264,11 +264,28 @@ function startBackgroundReindex() {
264
264
  console.error(`Reindex already running (PID ${existingPid}) — skipping`);
265
265
  reindexInProgress = true; // mark locally so tools know
266
266
  // Poll the external process and react when it finishes
267
+ const tempDbPath = config.dbPath + '.new';
267
268
  const pollInterval = setInterval(() => {
268
269
  if (!getRunningReindexPid()) {
269
270
  clearInterval(pollInterval);
270
271
  reindexInProgress = false;
271
- logToFile('INFO', 'External reindex finished. Restarting serve process.');
272
+ // Swap the new DB into place if the external reindex produced one
273
+ if (existsSync(tempDbPath)) {
274
+ try {
275
+ if (existsSync(config.dbPath)) {
276
+ const backupPath = config.dbPath + '.bak';
277
+ if (existsSync(backupPath)) { try { unlinkSync(backupPath); } catch {} }
278
+ renameSync(config.dbPath, backupPath);
279
+ logToFile('INFO', 'Old DB moved to .bak');
280
+ }
281
+ renameSync(tempDbPath, config.dbPath);
282
+ logToFile('INFO', 'External reindex complete — new index swapped into place.');
283
+ } catch (e) {
284
+ logToFile('ERR', `Failed to swap index after external reindex: ${e.message}`);
285
+ }
286
+ } else {
287
+ logToFile('INFO', 'External reindex finished but no .new file found — skipping swap.');
288
+ }
272
289
  if (serveProcess) serveProcess.kill();
273
290
  searchCache.clear();
274
291
  startServeProcess();