magector 1.2.3 → 1.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/model.js +7 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magector",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Semantic code search for Magento 2 — index, search, MCP server",
5
5
  "type": "module",
6
6
  "main": "src/mcp-server.js",
package/src/model.js CHANGED
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Downloads from HuggingFace if not found.
10
10
  */
11
- import { existsSync, mkdirSync, createWriteStream } from 'fs';
11
+ import { existsSync, statSync, mkdirSync, createWriteStream, unlinkSync } from 'fs';
12
12
  import { get as httpsGet } from 'https';
13
13
  import path from 'path';
14
14
  import os from 'os';
@@ -60,7 +60,10 @@ export function resolveModels() {
60
60
  }
61
61
 
62
62
  function hasModels(dir) {
63
- return MODEL_FILES.every(f => existsSync(path.join(dir, f.name)));
63
+ return MODEL_FILES.every(f => {
64
+ const p = path.join(dir, f.name);
65
+ return existsSync(p) && statSync(p).size > 0;
66
+ });
64
67
  }
65
68
 
66
69
  /**
@@ -79,7 +82,8 @@ export async function ensureModels({ silent = false } = {}) {
79
82
 
80
83
  for (const file of MODEL_FILES) {
81
84
  const dest = path.join(targetDir, file.name);
82
- if (existsSync(dest)) continue;
85
+ if (existsSync(dest) && statSync(dest).size > 0) continue;
86
+ if (existsSync(dest)) unlinkSync(dest);
83
87
 
84
88
  if (!silent) {
85
89
  process.stdout.write(` ${file.description} ... `);