datafolder 1.0.31 → 1.0.32
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/ChangeLog.md +2 -0
- package/package.json +1 -1
- package/scripts/fastify.js +2 -2
- package/scripts/flights2.js +31 -13
- package/src/QyBatch.d.ts +1 -0
- package/src/QyBatch.js +98 -96
- package/src/QyCache.js +38 -39
- package/src/QyDB.js +1 -1
- package/src/QyDefaultOptions.js +1 -1
- package/src/QyFile.js +16 -17
- package/src/QyFileContentUtils.d.ts +1 -4
- package/src/QyFileContentUtils.js +87 -105
- package/src/QyIndex.d.ts +1 -2
- package/src/QyIndex.js +105 -126
- package/src/QyIndexPropTree.d.ts +9 -6
- package/src/QyIndexPropTree.js +70 -35
- package/src/QyItem.d.ts +1 -1
- package/src/QyItem.js +2 -2
- package/src/QyTrigger.js +27 -27
package/ChangeLog.md
CHANGED
package/package.json
CHANGED
package/scripts/fastify.js
CHANGED
|
@@ -15,10 +15,10 @@ const config = {
|
|
|
15
15
|
const { port, staticRoot } = config;
|
|
16
16
|
const fastify = Fastify({ logger: false, forceCloseConnections: true });
|
|
17
17
|
// const qyDB = new QyDB(join(__dirname, "../tmp/flights2"));
|
|
18
|
-
const qyDB = new QyDB(join(__dirname, "../tmp/QyIndex/1"));
|
|
18
|
+
// const qyDB = new QyDB(join(__dirname, "../tmp/QyIndex/1"));
|
|
19
19
|
// const qyDB = new QyDB(join(__dirname, "../tmp/QyEmbeddings/1"));
|
|
20
20
|
// const qyDB = new QyDB("C:\\tmp\\hackernews");
|
|
21
|
-
|
|
21
|
+
const qyDB = new QyDB();
|
|
22
22
|
let sigintReceived = false;
|
|
23
23
|
process.on("SIGINT", async () => {
|
|
24
24
|
logger.log("SIGINT signal received: closing HTTP server");
|
package/scripts/flights2.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// node --prof profile.js
|
|
2
2
|
// node --prof-process isolate-0xnnnnnnnnnnnn-v8.log > processed.txt
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
import { rm } from "node:fs/promises";
|
|
4
|
+
import { rm, readFile } from "node:fs/promises";
|
|
6
5
|
import { QyDB } from "../src/QyDB.js";
|
|
7
6
|
import { folderOrFileExists } from "../src/QyUtils.js";
|
|
8
7
|
import { logger } from "../src/QyLogger.js";
|
|
@@ -11,13 +10,22 @@ logger.level = "info";
|
|
|
11
10
|
const arangoJsonFolderPath = "D:\\scripts\\GraphCourse_DemoData_ArangoDB-2";
|
|
12
11
|
const dataFolder = "./tmp/flights2";
|
|
13
12
|
const qyDB = new QyDB(dataFolder, { fileLogLevel: "basic", noAcl: false });
|
|
13
|
+
const maxBatchCount = 5000;
|
|
14
|
+
let airportsJson, flightsJson;
|
|
14
15
|
run();
|
|
16
|
+
async function loadData() {
|
|
17
|
+
const [airportsData, flightsData] = await Promise.all([
|
|
18
|
+
readFile(join(arangoJsonFolderPath, "airports.json")),
|
|
19
|
+
readFile(join(arangoJsonFolderPath, "flights.json")),
|
|
20
|
+
]);
|
|
21
|
+
airportsJson = JSON.parse(airportsData);
|
|
22
|
+
flightsJson = JSON.parse(flightsData);
|
|
23
|
+
}
|
|
15
24
|
function insertAirports() {
|
|
16
|
-
|
|
17
|
-
console.log(`airports:${data.length}`);
|
|
25
|
+
console.log(`airports:${airportsJson.length}`);
|
|
18
26
|
console.time("insertAirports");
|
|
19
27
|
const { batch } = qyDB;
|
|
20
|
-
for (const record of
|
|
28
|
+
for (const record of airportsJson) {
|
|
21
29
|
const { country, state, city } = record;
|
|
22
30
|
batch.insert(`airports/${country}/${state}/${city}/${record._key}`, record);
|
|
23
31
|
}
|
|
@@ -25,15 +33,20 @@ function insertAirports() {
|
|
|
25
33
|
console.timeEnd("insertAirports");
|
|
26
34
|
}
|
|
27
35
|
function insertFlights() {
|
|
28
|
-
const
|
|
29
|
-
console.log(`flights:${
|
|
36
|
+
const { length } = flightsJson;
|
|
37
|
+
console.log(`flights:${length}`);
|
|
30
38
|
console.time("insertFlights");
|
|
31
39
|
const { batch } = qyDB;
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
let count = 0;
|
|
41
|
+
for (let i = 0; i < length; ++i) {
|
|
42
|
+
const record = flightsJson[i];
|
|
34
43
|
const { Year, Month, Day } = record;
|
|
35
44
|
// batch.insert(`flights/${Year}/${Month}/${Day}/${i}`, record);
|
|
36
45
|
batch.insert(["flights", Year, Month, Day, i], record);
|
|
46
|
+
if (++count > maxBatchCount) {
|
|
47
|
+
batch.run();
|
|
48
|
+
count = 0;
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
51
|
batch.run();
|
|
39
52
|
console.timeEnd("insertFlights");
|
|
@@ -43,6 +56,10 @@ function insertFlights() {
|
|
|
43
56
|
for (const monthDir of yearDir.subdirList) {
|
|
44
57
|
for (const dayDir of monthDir.subdirList) {
|
|
45
58
|
batch.createIndex(dayDir, ["_from", "_to"]);
|
|
59
|
+
if (++count > maxBatchCount) {
|
|
60
|
+
batch.run();
|
|
61
|
+
count = 0;
|
|
62
|
+
}
|
|
46
63
|
}
|
|
47
64
|
}
|
|
48
65
|
}
|
|
@@ -50,25 +67,28 @@ function insertFlights() {
|
|
|
50
67
|
console.timeEnd("createFlightsIndex");
|
|
51
68
|
}
|
|
52
69
|
async function run() {
|
|
53
|
-
console.time("total");
|
|
54
70
|
if (process.argv[3]) {
|
|
55
71
|
logger.level = process.argv[3];
|
|
56
72
|
}
|
|
57
73
|
let shouldInsertData;
|
|
58
74
|
if (process.argv[2] === "true") {
|
|
75
|
+
console.time("rm");
|
|
59
76
|
try {
|
|
60
77
|
await rm(dataFolder, { recursive: true });
|
|
61
78
|
}
|
|
62
79
|
catch (exception) { }
|
|
80
|
+
console.timeEnd("rm");
|
|
63
81
|
shouldInsertData = true;
|
|
64
82
|
}
|
|
65
83
|
else if (!(await folderOrFileExists(dataFolder)))
|
|
66
84
|
shouldInsertData = true;
|
|
67
|
-
console.time("run");
|
|
68
85
|
console.time("start");
|
|
69
86
|
await qyDB.start();
|
|
70
87
|
console.timeEnd("start");
|
|
71
88
|
if (shouldInsertData) {
|
|
89
|
+
console.time("loadData");
|
|
90
|
+
await loadData();
|
|
91
|
+
console.timeEnd("loadData");
|
|
72
92
|
insertAirports();
|
|
73
93
|
insertFlights();
|
|
74
94
|
}
|
|
@@ -76,6 +96,4 @@ async function run() {
|
|
|
76
96
|
console.time("stop");
|
|
77
97
|
await qyDB.stop();
|
|
78
98
|
console.timeEnd("stop");
|
|
79
|
-
console.timeEnd("run");
|
|
80
|
-
console.timeEnd("total");
|
|
81
99
|
}
|
package/src/QyBatch.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare class QyBatch extends QyCD {
|
|
|
25
25
|
removeDirExpire(namePath: any, infoFileOnly?: any, parentDir?: any): any;
|
|
26
26
|
removeContentExpire(namePath: any, expireInfoObj: any, infoFileOnly?: any, parentDir?: any): any;
|
|
27
27
|
createIndex(indexHostDirNamePath: any, indexPropPathList: any, parentDir?: any): any;
|
|
28
|
+
createIndexFromQuery(indexHostDirNamePath: any, queryObj: any, parentDir?: any): any;
|
|
28
29
|
delIndex(indexHostDirNamePath: any, indexPropPath: any, parentDir?: any): any;
|
|
29
30
|
insert(namePath: any, content: any, noClone?: boolean, noCreate?: boolean, parentDir?: any): any;
|
|
30
31
|
insertEmbedding(namePath: any, embedding: any, parentDir?: any): any;
|
package/src/QyBatch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isDeepStrictEqual as
|
|
2
|
+
isDeepStrictEqual as c
|
|
3
3
|
} from "node:util";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -12,23 +12,23 @@ import {
|
|
|
12
12
|
isString as h,
|
|
13
13
|
getSuffix as g,
|
|
14
14
|
SpecialFilePaths as e,
|
|
15
|
-
toSingleName as
|
|
16
|
-
isSimpleType as
|
|
17
|
-
isEmptyObj as
|
|
15
|
+
toSingleName as f,
|
|
16
|
+
isSimpleType as d,
|
|
17
|
+
isEmptyObj as l,
|
|
18
18
|
isNumber as r,
|
|
19
19
|
getNowRounded as m,
|
|
20
20
|
isDate as a,
|
|
21
21
|
isArray as u,
|
|
22
|
-
isFloat32Array as
|
|
22
|
+
isFloat32Array as p
|
|
23
23
|
} from "./QyUtils.js";
|
|
24
24
|
|
|
25
25
|
import {
|
|
26
26
|
QyAclCmdGenerator as t,
|
|
27
|
-
CmdNames as
|
|
27
|
+
CmdNames as C
|
|
28
28
|
} from "./QyAcl.js";
|
|
29
29
|
|
|
30
30
|
import {
|
|
31
|
-
calDifferenceList as
|
|
31
|
+
calDifferenceList as _
|
|
32
32
|
} from "./QyIndex.js";
|
|
33
33
|
|
|
34
34
|
import {
|
|
@@ -92,13 +92,13 @@ class F extends v {
|
|
|
92
92
|
return this.expireFileM(e, 1e3 * t, i);
|
|
93
93
|
}
|
|
94
94
|
expireFileM(e, t, i = this.currentDir) {
|
|
95
|
-
return
|
|
95
|
+
return j(this, e, t, "f", i);
|
|
96
96
|
}
|
|
97
97
|
expireDir(e, t, i = this.currentDir) {
|
|
98
98
|
return this.expireDirM(e, 1e3 * t, i);
|
|
99
99
|
}
|
|
100
100
|
expireDirM(e, t, i = this.currentDir) {
|
|
101
|
-
return
|
|
101
|
+
return j(this, e, t, "d", i);
|
|
102
102
|
}
|
|
103
103
|
expireContent(e, t, i, r = this.currentDir) {
|
|
104
104
|
h(e) && (e = o(e));
|
|
@@ -135,6 +135,14 @@ class F extends v {
|
|
|
135
135
|
indexPropPathList: t
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
+
createIndexFromQuery(e, t, i = this.currentDir) {
|
|
139
|
+
h(e) && (e = o(e));
|
|
140
|
+
e = this.qyCache.getOrCreateDir(e, i);
|
|
141
|
+
return O(this, this._action_createIndex, {
|
|
142
|
+
item: e,
|
|
143
|
+
queryObj: t
|
|
144
|
+
});
|
|
145
|
+
}
|
|
138
146
|
delIndex(e, t, i = this.currentDir) {
|
|
139
147
|
h(e) && (e = o(e));
|
|
140
148
|
e = this.qyCache.getOrCreateDir(e, i);
|
|
@@ -146,14 +154,14 @@ class F extends v {
|
|
|
146
154
|
insert(e, t, i = !0, r = !1, n = this.currentDir) {
|
|
147
155
|
h(e) && (e = o(e));
|
|
148
156
|
e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
|
|
149
|
-
return t = i ||
|
|
157
|
+
return t = i || d(t) ? t : structuredClone(t), O(this, this._action_insert, {
|
|
150
158
|
item: e,
|
|
151
159
|
content: t,
|
|
152
160
|
noCreate: r
|
|
153
161
|
});
|
|
154
162
|
}
|
|
155
163
|
insertEmbedding(e, t, i = this.currentDir) {
|
|
156
|
-
var r = this.qyCache, r = (
|
|
164
|
+
var r = this.qyCache, r = (p(t) || (t = new Float32Array(t)), h(e) && (e = o(e)),
|
|
157
165
|
r.getOrCreateFile(e, i));
|
|
158
166
|
return O(this, this._action_insertEmbedding, {
|
|
159
167
|
item: r,
|
|
@@ -220,16 +228,16 @@ class F extends v {
|
|
|
220
228
|
qyAclCmdGenerator: o,
|
|
221
229
|
qyCmdObjHistory: s,
|
|
222
230
|
syncList: h
|
|
223
|
-
} = this,
|
|
224
|
-
if (0 ===
|
|
225
|
-
var
|
|
226
|
-
let
|
|
231
|
+
} = this, d = i.length;
|
|
232
|
+
if (0 === d) return n.decreaseChangeId(), 0;
|
|
233
|
+
var c = g(d), o = o.takeCmdArgAsListObj();
|
|
234
|
+
let l;
|
|
227
235
|
0 < r && (r = i.map(({
|
|
228
236
|
logStr: e
|
|
229
|
-
}) => e).join("\n"),
|
|
237
|
+
}) => e).join("\n"), l = new Date().toISOString() + `: ${d} change${c}:
|
|
230
238
|
${r}
|
|
231
239
|
`);
|
|
232
|
-
var m, u,
|
|
240
|
+
var m, u, d = n.save(t, o, l, (e => {
|
|
233
241
|
var t = e.syncList, i = t.length;
|
|
234
242
|
for (let e = 0; e < i; e += 2) {
|
|
235
243
|
var r, n = e + 1, a = t[e], o = t[n];
|
|
@@ -237,16 +245,16 @@ ${r}
|
|
|
237
245
|
t[n] = 0 < r.length ? r : void 0) : t[n] = o.fileContent;
|
|
238
246
|
}
|
|
239
247
|
if (0 < i) return t;
|
|
240
|
-
})(this), e),
|
|
248
|
+
})(this), e), c = (h.length = 0, s.push(o), i.filter(({
|
|
241
249
|
item: e,
|
|
242
250
|
delta: t
|
|
243
|
-
}) => t && 0 < e.triggerNodes?.length));
|
|
251
|
+
}) => void 0 !== t && 0 < e.triggerNodes?.length));
|
|
244
252
|
i.length = 0;
|
|
245
253
|
for ({
|
|
246
254
|
item: m,
|
|
247
255
|
delta: u
|
|
248
|
-
} of
|
|
249
|
-
return e ?
|
|
256
|
+
} of c) for (var f of m.triggerNodes) f.checkTrigger(m, u);
|
|
257
|
+
return e ? d : t;
|
|
250
258
|
}
|
|
251
259
|
getTopHistoryCmdObj() {
|
|
252
260
|
return this.qyCmdObjHistory.top();
|
|
@@ -265,7 +273,7 @@ ${r}
|
|
|
265
273
|
item: e,
|
|
266
274
|
content: o
|
|
267
275
|
}));
|
|
268
|
-
return e && (o = this.qyCache, a && !
|
|
276
|
+
return e && (o = this.qyCache, a && !c(a, t) && o.removeTriggerFromTree(n, a),
|
|
269
277
|
o.insertTriggerToTree(n, t, i, r)), e;
|
|
270
278
|
}
|
|
271
279
|
_action_removeTrigger(e) {
|
|
@@ -298,39 +306,38 @@ ${r}
|
|
|
298
306
|
}
|
|
299
307
|
_action_createIndex(t) {
|
|
300
308
|
t.actionName = "createIndex";
|
|
301
|
-
var
|
|
309
|
+
var {
|
|
302
310
|
item: t,
|
|
303
|
-
indexPropPathList:
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
y.log(`Creating index ${JSON.stringify(o.map(e => e.indexPropPath))} for ` + t.fullPath),
|
|
315
|
-
this._action_insert({
|
|
316
|
-
item: n,
|
|
317
|
-
content: l
|
|
311
|
+
indexPropPathList: e,
|
|
312
|
+
queryObj: i
|
|
313
|
+
} = t, r = this.qyCache.getOrCreateIndexDir(t), r = r.getOrCreateFile(x), n = (r.created || this._action_createFile({
|
|
314
|
+
item: r
|
|
315
|
+
}), r).qyIndexPropTree, i = void 0 !== i ? n.insertFromQueryObj(i) : n.insertPropPathList(e);
|
|
316
|
+
if (0 !== i.length) {
|
|
317
|
+
var a, o = {};
|
|
318
|
+
for (a of i) o[f(a.indexPropPath)] = 1;
|
|
319
|
+
y.log(`Creating index ${JSON.stringify(o)} for ` + t.fullPath), this._action_insert({
|
|
320
|
+
item: r,
|
|
321
|
+
content: o
|
|
318
322
|
});
|
|
319
323
|
{
|
|
320
|
-
var
|
|
324
|
+
var s, h = this, d = t;
|
|
321
325
|
let e;
|
|
322
|
-
for (
|
|
323
|
-
var
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
326
|
+
for (s of i) {
|
|
327
|
+
var {
|
|
328
|
+
indexPropPath: c,
|
|
329
|
+
indexPropDir: l
|
|
330
|
+
} = s;
|
|
331
|
+
if (!l.created) {
|
|
332
|
+
h._action_createDir({
|
|
333
|
+
item: l
|
|
327
334
|
});
|
|
328
|
-
for (var
|
|
335
|
+
for (var m of e = void 0 === e ? d.fileList : e) {
|
|
329
336
|
var {
|
|
330
|
-
fileContent:
|
|
331
|
-
name:
|
|
332
|
-
} =
|
|
333
|
-
void 0 !==
|
|
337
|
+
fileContent: m,
|
|
338
|
+
name: u
|
|
339
|
+
} = m;
|
|
340
|
+
void 0 !== m && N(h, l, c, u, void 0, m);
|
|
334
341
|
}
|
|
335
342
|
}
|
|
336
343
|
}
|
|
@@ -343,8 +350,8 @@ ${r}
|
|
|
343
350
|
item: e,
|
|
344
351
|
indexPropPath: r
|
|
345
352
|
} = e, e = this.qyCache.getIndexDir(e);
|
|
346
|
-
e && ((i = e.getFile(x)) ? (t = i.qyIndexPropTree, this._setProp(i,
|
|
347
|
-
t.remove(r)
|
|
353
|
+
void 0 !== e && ((i = e.getFile(x)) ? (t = i.qyIndexPropTree, [ i, t, r ] = (this._setProp(i, f(r), null),
|
|
354
|
+
t.remove(r)), i && !t && void 0 !== r && (i = r.indexPropDir, void 0 !== i) && this._action_delDir({
|
|
348
355
|
item: i
|
|
349
356
|
})) : this._action_delDir({
|
|
350
357
|
item: e
|
|
@@ -361,7 +368,7 @@ ${r}
|
|
|
361
368
|
parentDir: r,
|
|
362
369
|
name: n
|
|
363
370
|
} = i;
|
|
364
|
-
return i.created = !1, P(this, e), t || q(this, r,
|
|
371
|
+
return i.created = !1, P(this, e), t || q(this, r, C.R, r.fileMapKey, n),
|
|
365
372
|
!0;
|
|
366
373
|
}
|
|
367
374
|
_action_delDir(e) {
|
|
@@ -377,42 +384,40 @@ ${r}
|
|
|
377
384
|
fileMapKey: s
|
|
378
385
|
} = t;
|
|
379
386
|
if (a) {
|
|
380
|
-
q(this, t,
|
|
387
|
+
q(this, t, C.D, s);
|
|
381
388
|
for (var h of t.fileList) this._action_delFile({
|
|
382
389
|
item: h
|
|
383
390
|
}, !0);
|
|
384
391
|
}
|
|
385
392
|
if (n) {
|
|
386
|
-
q(this, t,
|
|
387
|
-
for (var
|
|
393
|
+
q(this, t, C.D, o);
|
|
394
|
+
for (var d of t.allSubdirs()) {
|
|
388
395
|
let {
|
|
389
396
|
subdirMap: e,
|
|
390
397
|
fileMap: t,
|
|
391
398
|
subdirMapKey: i,
|
|
392
399
|
fileMapKey: r
|
|
393
|
-
} =
|
|
394
|
-
if (e && q(this,
|
|
395
|
-
q(this,
|
|
396
|
-
for (var
|
|
397
|
-
item:
|
|
400
|
+
} = d;
|
|
401
|
+
if (e && q(this, d, C.D, i), t) {
|
|
402
|
+
q(this, d, C.D, r);
|
|
403
|
+
for (var c of d.fileList) this._action_delFile({
|
|
404
|
+
item: c
|
|
398
405
|
}, !0);
|
|
399
406
|
}
|
|
400
407
|
P(this, {
|
|
401
408
|
actionName: "delDir",
|
|
402
|
-
item:
|
|
403
|
-
}),
|
|
409
|
+
item: d
|
|
410
|
+
}), d.created = !1;
|
|
404
411
|
}
|
|
405
412
|
}
|
|
406
|
-
return void 0 !== i && (t.created = !1, P(this, e), q(this, i,
|
|
413
|
+
return void 0 !== i && (t.created = !1, P(this, e), q(this, i, C.R, i.subdirMapKey, r),
|
|
407
414
|
!0);
|
|
408
415
|
}
|
|
409
416
|
_action_delContent(e) {
|
|
410
417
|
e.actionName = "delContent";
|
|
411
418
|
var t = e.item, i = t.fileContent;
|
|
412
|
-
return void 0 !== i && (t.fileContent = void 0, e.content = i, e.delta =
|
|
413
|
-
|
|
414
|
-
newValue: null
|
|
415
|
-
}, P(this, e), q(this, t, p.D, t.fileContentKey), N(this, t, i), !0);
|
|
419
|
+
return void 0 !== i && (t.fileContent = void 0, e.content = i, e.delta = [ i, null ],
|
|
420
|
+
P(this, e), q(this, t, C.D, t.fileContentKey), L(this, t, i), !0);
|
|
416
421
|
}
|
|
417
422
|
_action_insertEmbedding(e) {
|
|
418
423
|
e.actionName = "insertEmbedding";
|
|
@@ -420,10 +425,10 @@ ${r}
|
|
|
420
425
|
item: a,
|
|
421
426
|
embedding: o
|
|
422
427
|
} = e, s = o.length, r = r.getOrCreateInfoFile(a), h = r.fileContent;
|
|
423
|
-
let
|
|
428
|
+
let d = !1;
|
|
424
429
|
return r.created && h.length === s ? (t = a.fullPathHash, h = h.idx, i = n.getEmbedding(t, s, h),
|
|
425
|
-
|
|
426
|
-
|
|
430
|
+
c(o, i) || ((i = n.updateEmbedding(t, o, h)) !== h && this._setProp(r, "idx", i),
|
|
431
|
+
d = !0)) : ({
|
|
427
432
|
fullPathHash: t,
|
|
428
433
|
namePath: h
|
|
429
434
|
} = a, i = n.addEmbedding(t, o), this._action_insert({
|
|
@@ -433,7 +438,7 @@ ${r}
|
|
|
433
438
|
idx: i,
|
|
434
439
|
namePath: r.created ? void 0 : h
|
|
435
440
|
}
|
|
436
|
-
}),
|
|
441
|
+
}), d = !0), d && P(this, e), d;
|
|
437
442
|
}
|
|
438
443
|
_action_delEmbedding(e) {
|
|
439
444
|
e.actionName = "delEmbedding";
|
|
@@ -457,7 +462,7 @@ ${r}
|
|
|
457
462
|
item: t
|
|
458
463
|
});
|
|
459
464
|
var r = t.fileContentKey;
|
|
460
|
-
return i.$rpl = 1, q(this, t,
|
|
465
|
+
return i.$rpl = 1, q(this, t, C.M, r, i), P(this, e), t.fileContent = i,
|
|
461
466
|
!0;
|
|
462
467
|
}
|
|
463
468
|
_setProp(e, t, i) {
|
|
@@ -470,7 +475,7 @@ ${r}
|
|
|
470
475
|
}), a ? a[t] : void 0);
|
|
471
476
|
return null === i ? void 0 !== a && delete a[t] : void 0 !== a ? a[t] = i : e.fileContent = {
|
|
472
477
|
[t]: i
|
|
473
|
-
}, q(this, e,
|
|
478
|
+
}, q(this, e, C.M, n, t, i), r;
|
|
474
479
|
}
|
|
475
480
|
_action_insert(e) {
|
|
476
481
|
e.actionName = "insert";
|
|
@@ -491,12 +496,9 @@ ${r}
|
|
|
491
496
|
item: i
|
|
492
497
|
});
|
|
493
498
|
}
|
|
494
|
-
return void 0 === a && void 0 === o && (
|
|
495
|
-
o =
|
|
496
|
-
|
|
497
|
-
newValue: n
|
|
498
|
-
} = o, t = i.fileContentKey, void 0 === a ? q(this, i, p.D, t) : q(this, i, p.M, t, n),
|
|
499
|
-
e.merged = a, e.delta = o, P(this, e), i.fileContent = a, N(this, i, r, n, a),
|
|
499
|
+
return void 0 === a && void 0 === o && ([ a, o ] = s(i.fileContent, r)),
|
|
500
|
+
void 0 !== o && ([ n, r ] = o, t = i.fileContentKey, void 0 === a ? q(this, i, C.D, t) : q(this, i, C.M, t, r),
|
|
501
|
+
e.merged = a, e.delta = o, P(this, e), i.fileContent = a, L(this, i, n, r, a),
|
|
500
502
|
!0);
|
|
501
503
|
}
|
|
502
504
|
_action_createFile(e) {
|
|
@@ -504,7 +506,7 @@ ${r}
|
|
|
504
506
|
var t, i = e.item;
|
|
505
507
|
return !i.created && (t = i.parentDir, this._action_createDir({
|
|
506
508
|
item: t
|
|
507
|
-
}), i.created = !0, i.fileContentLoaded = !0, P(this, e), q(this, t,
|
|
509
|
+
}), i.created = !0, i.fileContentLoaded = !0, P(this, e), q(this, t, C.A, t.fileMapKey, i.name),
|
|
508
510
|
!0);
|
|
509
511
|
}
|
|
510
512
|
_action_createDir(e) {
|
|
@@ -518,7 +520,7 @@ ${r}
|
|
|
518
520
|
item: e
|
|
519
521
|
});
|
|
520
522
|
var r = e.parentDir;
|
|
521
|
-
q(this, r,
|
|
523
|
+
q(this, r, C.A, r.subdirMapKey, e.name);
|
|
522
524
|
}
|
|
523
525
|
return !0;
|
|
524
526
|
}
|
|
@@ -553,7 +555,7 @@ ${r}
|
|
|
553
555
|
content: {
|
|
554
556
|
[n]: null
|
|
555
557
|
}
|
|
556
|
-
})) && (
|
|
558
|
+
})) && (l(r.fileContent) && this._action_delFile({
|
|
557
559
|
item: r
|
|
558
560
|
}), void 0 === i) && t.unmonitorItemExpire(e), n);
|
|
559
561
|
}
|
|
@@ -583,7 +585,7 @@ ${r}
|
|
|
583
585
|
(t = this._action_insert({
|
|
584
586
|
item: a,
|
|
585
587
|
content: i
|
|
586
|
-
})) && (
|
|
588
|
+
})) && (l(a.fileContent, !0) && this._action_delFile({
|
|
587
589
|
item: a
|
|
588
590
|
}), r || n.unmonitorContentExpire(e, i)), t);
|
|
589
591
|
}
|
|
@@ -609,10 +611,7 @@ function P(e, t) {
|
|
|
609
611
|
} = e, i = e + ` "${i.fullPath ?? i}"`;
|
|
610
612
|
if ("delContent" === e) {
|
|
611
613
|
if (3 === t) return i + " " + JSON.stringify(r);
|
|
612
|
-
} else if ("insert" === e && 2 <= t) return {
|
|
613
|
-
oldValue: r,
|
|
614
|
-
newValue: e
|
|
615
|
-
} = a, a = `${void 0 === r ? "" : "delta:"} ${JSON.stringify(r)} -> ` + JSON.stringify(e),
|
|
614
|
+
} else if ("insert" === e && 2 <= t) return [ r, e ] = a, a = `${void 0 === r ? "" : "delta:"} ${JSON.stringify(r)} -> ` + JSON.stringify(e),
|
|
616
615
|
2 === t ? i + " " + a : i + ` ${a}. ` + (void 0 !== r ? "new: " + JSON.stringify(n) : "");
|
|
617
616
|
return i;
|
|
618
617
|
})(t, i)), e.push(t);
|
|
@@ -629,27 +628,30 @@ function q(e, t, i, r, n = void 0, a = void 0) {
|
|
|
629
628
|
o && o.qyKVData.removeKey(r) && s.push(r, t);
|
|
630
629
|
}
|
|
631
630
|
|
|
632
|
-
function
|
|
631
|
+
function L(e, t, i, r = void 0, n = void 0) {
|
|
633
632
|
if (!t.underHiddenFolder) {
|
|
634
633
|
var a = e.qyCache.getIndexDir(t.parentDir);
|
|
635
634
|
if (void 0 !== a) {
|
|
636
635
|
a = a.getFile(x);
|
|
637
636
|
if (void 0 !== a) {
|
|
638
|
-
var o, s = t.name;
|
|
639
|
-
for (
|
|
637
|
+
var o, s, h = t.name;
|
|
638
|
+
for ({
|
|
639
|
+
indexPropDir: o,
|
|
640
|
+
indexPropPath: s
|
|
641
|
+
} of a.qyIndexPropTree.allLeafNodes) N(e, o, s, h, i, r, n);
|
|
640
642
|
}
|
|
641
643
|
}
|
|
642
644
|
}
|
|
643
645
|
}
|
|
644
646
|
|
|
645
|
-
function
|
|
646
|
-
e =
|
|
647
|
+
function N(t, e, i, r, n, a, o = void 0) {
|
|
648
|
+
e = _(e, i, n, a, o);
|
|
647
649
|
if (void 0 !== e) {
|
|
648
650
|
var s, h, [ i, n ] = e;
|
|
649
651
|
for (s of i) {
|
|
650
652
|
t._setProp(s, r, null);
|
|
651
|
-
var
|
|
652
|
-
if (void 0 ===
|
|
653
|
+
var d = s.fileContent;
|
|
654
|
+
if (void 0 === d || l(d)) {
|
|
653
655
|
t._action_delFile({
|
|
654
656
|
item: s
|
|
655
657
|
});
|
|
@@ -692,7 +694,7 @@ class b {
|
|
|
692
694
|
}
|
|
693
695
|
|
|
694
696
|
function I(e, t = void 0, i = [], r = {}) {
|
|
695
|
-
if (
|
|
697
|
+
if (d(e)) {
|
|
696
698
|
var n = t ? t(e) : e;
|
|
697
699
|
void 0 !== n && (r[JSON.stringify(i)] = n);
|
|
698
700
|
} else {
|
|
@@ -706,7 +708,7 @@ function E(e, t, i) {
|
|
|
706
708
|
return r(e) ? (t ? e : 1e3 * e) + i : h(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !a(e) || (t = e.getTime()) <= i ? void 0 : t;
|
|
707
709
|
}
|
|
708
710
|
|
|
709
|
-
function
|
|
711
|
+
function j(e, t, i, r, n) {
|
|
710
712
|
var a = e.qyCache, r = (h(t) && (t = o(t)), "f" === r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
711
713
|
return O(e, e._action_expireItem, {
|
|
712
714
|
item: r,
|