MCPcopy
hub / github.com/CaviraOSS/OpenMemory / imp

Method imp

migrate/imp.js:16–41  ·  view source on GitHub ↗
(f)

Source from the content-addressed store, hash-verified

14 };
15 }
16 async imp(f) {
17 const t0 = Date.now();
18 let mc = 0,
19 fc = 0;
20 const rd = rl.createInterface({
21 input: fs.createReadStream(f),
22 crlfDelay: Infinity,
23 });
24 console.log('[IMPORT] Processing export file...');
25 console.log(`[IMPORT] Target: ${this.u}`);
26 for await (const ln of rd) {
27 try {
28 const d = JSON.parse(ln);
29 await this.pm(d);
30 mc++;
31 if (mc % 100 === 0)
32 console.log(`[IMPORT] Progress: ${mc} memories imported`);
33 } catch (e) {
34 fc++;
35 console.error(`[IMPORT] Warning: Skipped record - ${e.message}`);
36 }
37 }
38 rd.close();
39 const dur = ((Date.now() - t0) / 1000).toFixed(1);
40 return { m: mc, f: fc, d: dur };
41 }
42 async pm(d) {
43 const payload = {
44 content: d.c,

Callers 1

runFunction · 0.95

Calls 2

pmMethod · 0.95
closeMethod · 0.80

Tested by

no test coverage detected