datafolder 1.0.18 → 1.0.20

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/src/QyBatch.js CHANGED
@@ -1,32 +1,32 @@
1
1
  import {
2
- isDeepStrictEqual as o
2
+ isDeepStrictEqual as h
3
3
  } from "node:util";
4
4
 
5
5
  import {
6
- mergeContentAndGenDelta as l,
6
+ mergeContentAndGenDelta as s,
7
7
  objToDelMarks as r
8
8
  } from "./QyFileContentUtils.js";
9
9
 
10
10
  import {
11
- pathSplit as s,
11
+ pathSplit as o,
12
12
  ensurePropNamePathList as n,
13
- isString as c,
13
+ isString as l,
14
14
  SpecialOperators as e,
15
- getSuffix as g,
15
+ getSuffix as f,
16
16
  SpecialFilePaths as t,
17
17
  toSingleName as p,
18
- isSimpleType as h,
19
- isEmptyObj as d,
18
+ isSimpleType as c,
19
+ isEmptyObj as m,
20
20
  isNumber as a,
21
- getNowRounded as m,
21
+ getNowRounded as d,
22
22
  isDate as u,
23
- isArray as f,
23
+ isArray as g,
24
24
  isFloat32Array as C
25
25
  } from "./QyUtils.js";
26
26
 
27
27
  import {
28
28
  QyAclCmdGenerator as i,
29
- CmdNames as y
29
+ CmdNames as _
30
30
  } from "./QyAcl.js";
31
31
 
32
32
  import {
@@ -34,7 +34,7 @@ import {
34
34
  } from "./QyIndex.js";
35
35
 
36
36
  import {
37
- getDefaultOptions as _
37
+ getDefaultOptions as y
38
38
  } from "./QyDefaultOptions.js";
39
39
 
40
40
  import {
@@ -49,7 +49,7 @@ import {
49
49
  logger as F
50
50
  } from "./QyLogger.js";
51
51
 
52
- let O = e.$del, L = t.IndexPropPathsFileName, q = {
52
+ let O = e.$del, b = t.IndexPropPathsFileName, L = {
53
53
  none: 0,
54
54
  basic: 1,
55
55
  delta: 2,
@@ -67,31 +67,39 @@ class Q extends D {
67
67
  running;
68
68
  constructor(e, t) {
69
69
  super(e), t = {
70
- ..._("QyBatch"),
70
+ ...y("QyBatch"),
71
71
  ...t
72
72
  };
73
- e = q[t.fileLogLevel.toLowerCase()];
73
+ e = L[t.fileLogLevel.toLowerCase()];
74
74
  Object.assign(this, {
75
75
  options: t,
76
76
  fileLogLevel: e ?? 1,
77
77
  qyAclCmdGenerator: new i(),
78
- qyCmdObjHistory: new H(t.maxHistoryCmdObjCount),
78
+ qyCmdObjHistory: new A(t.maxHistoryCmdObjCount),
79
79
  actionQueue: [],
80
80
  changeList: [],
81
81
  syncList: []
82
82
  });
83
83
  }
84
84
  createDir(e, t = this.currentDir) {
85
- return c(e) && (e = s(e)), N(this, "createDir", this.qyCache.getOrCreateDir(e, t));
85
+ return l(e) && (e = o(e)), q(this, this._action_createDir, {
86
+ item: this.qyCache.getOrCreateDir(e, t)
87
+ });
86
88
  }
87
89
  delDir(e, t = this.currentDir) {
88
- return c(e) && (e = s(e)), N(this, "delDir", this.qyCache.getOrCreateDir(e, t).ensureAllLoaded());
90
+ return l(e) && (e = o(e)), q(this, this._action_delDir, {
91
+ item: this.qyCache.getOrCreateDir(e, t).ensureAllLoaded()
92
+ });
89
93
  }
90
94
  createFile(e, t = this.currentDir) {
91
- return c(e) && (e = s(e)), N(this, "createFile", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
95
+ return l(e) && (e = o(e)), q(this, this._action_createFile, {
96
+ item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
97
+ });
92
98
  }
93
99
  delFile(e, t = this.currentDir) {
94
- return c(e) && (e = s(e)), N(this, "delFile", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
100
+ return l(e) && (e = o(e)), q(this, this._action_delFile, {
101
+ item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
102
+ });
95
103
  }
96
104
  expireFile(e, t, i = this.currentDir) {
97
105
  return this.expireFileM(e, 1e3 * t, i);
@@ -106,9 +114,10 @@ class Q extends D {
106
114
  return T(this, e, t, "d", i);
107
115
  }
108
116
  expireContent(e, t, i, r = this.currentDir) {
109
- c(e) && (e = s(e));
117
+ l(e) && (e = o(e));
110
118
  e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
111
- return N(this, "expireContent", e, {
119
+ return q(this, this._action_expireContent, {
120
+ item: e,
112
121
  expireInfoObj: t,
113
122
  isMilliSecond: i
114
123
  });
@@ -123,72 +132,100 @@ class Q extends D {
123
132
  return M(this, e, "d", t, i);
124
133
  }
125
134
  removeContentExpire(e, t, i = !1, r = this.currentDir) {
126
- c(e) && (e = s(e));
135
+ l(e) && (e = o(e));
127
136
  e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
128
- return N(this, "removeContentExpire", e, {
137
+ return q(this, this._action_removeContentExpire, {
138
+ item: e,
129
139
  expireInfoObj: t,
130
140
  infoFileOnly: i
131
141
  });
132
142
  }
133
143
  createIndex(e, t, i = this.currentDir) {
134
- return c(e) && (e = s(e)), f(t) || (t = [ t ]), N(this, "createIndex", this.qyCache.getOrCreateDir(e, i), {
144
+ l(e) && (e = o(e)), g(t) || (t = [ t ]);
145
+ e = this.qyCache.getOrCreateDir(e, i);
146
+ return q(this, this._action_createIndex, {
147
+ item: e,
135
148
  indexPropPathList: t
136
149
  });
137
150
  }
138
151
  delIndex(e, t, i = this.currentDir) {
139
- return c(e) && (e = s(e)), N(this, "delIndex", this.qyCache.getOrCreateDir(e, i), {
152
+ l(e) && (e = o(e));
153
+ e = this.qyCache.getOrCreateDir(e, i);
154
+ return q(this, this._action_delIndex, {
155
+ item: e,
140
156
  indexPropPath: t
141
157
  });
142
158
  }
143
159
  insert(e, t, i = !1, r = !1, n = this.currentDir) {
144
- c(e) && (e = s(e));
160
+ l(e) && (e = o(e));
145
161
  e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
146
- return N(this, "insert", e, {
147
- content: i || h(t) ? t : structuredClone(t),
162
+ return t = i || c(t) ? t : structuredClone(t), q(this, this._action_insert, {
163
+ item: e,
164
+ content: t,
148
165
  noCreate: r
149
166
  });
150
167
  }
151
168
  insertEmbedding(e, t, i = this.currentDir) {
152
- var r = this.qyCache, e = (c(e) && (e = s(e)), r.getOrCreateFile(e, i));
153
- return N(this, "insertEmbedding", r.getOrCreateEmbeddingFile(e.fullPathHash), {
154
- content: C(t) ? t : new Float32Array(t),
155
- srcFile: e
169
+ var r = this.qyCache, r = (C(t) || (t = new Float32Array(t)), l(e) && (e = o(e)),
170
+ r.getOrCreateFile(e, i));
171
+ return q(this, this._action_insertEmbedding, {
172
+ item: r,
173
+ embedding: t
156
174
  });
157
175
  }
158
176
  delEmbedding(e, t = this.currentDir) {
159
- var i = this.qyCache, e = (c(e) && (e = s(e)), i.getOrCreateFile(e, t));
160
- return N(this, "delEmbedding", i.getOrCreateEmbeddingFile(e.fullPathHash), {
161
- srcFile: e
177
+ var i = this.qyCache, i = (l(e) && (e = o(e)), i.getOrCreateFile(e, t));
178
+ return q(this, this._action_delEmbedding, {
179
+ item: i
162
180
  });
163
181
  }
182
+ insertWithEmbedding(e, t, i, r = !1, n = !1, a = this.currentDir) {
183
+ return this.insert(e, t, r, n, a), this.insertEmbedding(e, i, a);
184
+ }
164
185
  remove(e, t, i = this.currentDir) {
165
186
  return this.insert(e, r(t), !0, !0, i);
166
187
  }
167
- put(e, t, i = !1, r = this.currentDir) {
168
- return this.insert(e, {
169
- $rpl: t
170
- }, i, !1, r);
188
+ put(e, t, i = this.currentDir) {
189
+ l(e) && (e = o(e));
190
+ e = this.qyCache.getOrCreateFile(e, i).ensureLoaded();
191
+ return q(this, this._action_put, {
192
+ item: e,
193
+ content: t
194
+ });
171
195
  }
172
196
  delContent(e, t = this.currentDir) {
173
- return c(e) && (e = s(e)), N(this, "delContent", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
197
+ l(e) && (e = o(e));
198
+ e = this.qyCache.getOrCreateFile(e, t).ensureLoaded();
199
+ return q(this, this._action_delContent, {
200
+ item: e
201
+ });
174
202
  }
175
203
  insertTrigger(e, t, i, r) {
176
- return c(t) && (t = s(t)), i = n(i), N(this, "insertTrigger", this.qyCache.getOrCreateTriggerFile(e), {
204
+ l(t) && (t = o(t)), i = n(i);
205
+ e = this.qyCache.getOrCreateTriggerFile(e);
206
+ return q(this, this._action_insertTrigger, {
207
+ item: e,
177
208
  fileNamePath: t,
178
209
  propNamePathList: i,
179
210
  modCode: r
180
211
  });
181
212
  }
182
213
  removeTrigger(e) {
183
- return N(this, "removeTrigger", this.qyCache.getOrCreateTriggerFile(e));
214
+ return q(this, this._action_removeTrigger, {
215
+ item: this.qyCache.getOrCreateTriggerFile(e)
216
+ });
184
217
  }
185
218
  insertRpc(e, t) {
186
- return N(this, "insertRpc", this.qyCache.getOrCreateRpcFile(e), {
219
+ e = this.qyCache.getOrCreateRpcFile(e);
220
+ return q(this, this._action_insertRpc, {
221
+ item: e,
187
222
  modCode: t
188
223
  });
189
224
  }
190
225
  removeRpc(e) {
191
- return N(this, "removeRpc", this.qyCache.getOrCreateRpcFile(e));
226
+ return q(this, this._action_removeRpc, {
227
+ item: this.qyCache.getOrCreateRpcFile(e)
228
+ });
192
229
  }
193
230
  run(e = !1) {
194
231
  var {
@@ -200,31 +237,31 @@ class Q extends D {
200
237
  if (t || 0 == i.length) return 0;
201
238
  this.running = !0;
202
239
  var a, t = this.changeId = n.increaseChangeId();
203
- for (a of i) this["_action_" + a.actionName](a);
240
+ for (a of i) a.actionFun.call(this, a);
204
241
  i.length = 0, this.running = !1, this.resetCurrentDir();
205
242
  var {
206
243
  changeList: i,
207
- qyAclCmdGenerator: s,
208
- qyCmdObjHistory: o,
244
+ qyAclCmdGenerator: o,
245
+ qyCmdObjHistory: s,
209
246
  syncList: l
210
247
  } = this, c = i.length;
211
248
  if (0 == c) return n.decreaseChangeId(), 0;
212
- var h = g(c), s = s.takeCmdArgAsListObj();
249
+ var h = f(c), o = o.takeCmdArgAsListObj();
213
250
  let d;
214
251
  0 < r && (r = i.map(({
215
252
  logStr: e
216
253
  }) => e).join("\n"), d = new Date().toISOString() + `: ${c} change${h}:
217
254
  ${r}
218
255
  `);
219
- var m, u, c = n.save(t, s, d, (e => {
256
+ var m, u, c = n.save(t, o, d, (e => {
220
257
  var t = e.syncList, i = t.length;
221
258
  for (let e = 0; e < i; e += 2) {
222
- var r, n = e + 1, a = t[e], s = t[n];
223
- a.startsWith("d") ? (r = s.subdirNameList, t[n] = 0 < r.length ? r : void 0) : a.startsWith("f") ? (r = s.fileNameList,
224
- t[n] = 0 < r.length ? r : void 0) : t[n] = s.fileContent;
259
+ var r, n = e + 1, a = t[e], o = t[n];
260
+ a.startsWith("d") ? (r = o.subdirNameList, t[n] = 0 < r.length ? r : void 0) : a.startsWith("f") ? (r = o.fileNameList,
261
+ t[n] = 0 < r.length ? r : void 0) : t[n] = o.fileContent;
225
262
  }
226
263
  if (0 < i) return t;
227
- })(this), e), h = (l.length = 0, o.push(s), i.filter(({
264
+ })(this), e), h = (l.length = 0, s.push(o), i.filter(({
228
265
  item: e,
229
266
  delta: t
230
267
  }) => t && 0 < e.triggerNodes?.length));
@@ -232,7 +269,7 @@ ${r}
232
269
  for ({
233
270
  item: m,
234
271
  delta: u
235
- } of h) for (var f of m.triggerNodes) f.checkTrigger(m, u);
272
+ } of h) for (var g of m.triggerNodes) g.checkTrigger(m, u);
236
273
  return e ? c : t;
237
274
  }
238
275
  getTopHistoryCmdObj() {
@@ -247,12 +284,12 @@ ${r}
247
284
  modCode: n
248
285
  } = e, {
249
286
  name: a,
250
- fileContent: s
251
- } = e, s = s && s[0], e = this._action_insert({
287
+ fileContent: o
288
+ } = e, o = o && o[0], e = this._action_insert({
252
289
  item: e,
253
290
  content: [ i, r, n ]
254
291
  });
255
- return e && (t = this.qyCache, s && !o(s, i) && t.removeTriggerFromTree(a, s),
292
+ return e && (t = this.qyCache, o && !h(o, i) && t.removeTriggerFromTree(a, o),
256
293
  t.insertTriggerToTree(a, i, r, n)), e;
257
294
  }
258
295
  _action_removeTrigger(e) {
@@ -288,36 +325,36 @@ ${r}
288
325
  var e, {
289
326
  item: t,
290
327
  indexPropPathList: i
291
- } = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(L), {
328
+ } = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(b), {
292
329
  fileContent: a,
293
- qyIndexPropTree: s
330
+ qyIndexPropTree: o
294
331
  } = (n.created || this._action_createFile({
295
332
  item: n
296
- }), n), o = [], l = {};
333
+ }), n), s = [], l = {};
297
334
  for (e of i) {
298
335
  var c = p(e);
299
- a && a[c] || (o.push(e), l[c] = 1, s.insert(e));
336
+ a && a[c] || (s.push(e), l[c] = 1, o.insert(e));
300
337
  }
301
- if (0 != o.length) {
302
- F.log(`Creating index ${JSON.stringify(o)} for ` + t.fullPath), this._action_insert({
338
+ if (0 != s.length) {
339
+ F.log(`Creating index ${JSON.stringify(s)} for ` + t.fullPath), this._action_insert({
303
340
  item: n,
304
341
  content: l
305
342
  });
306
343
  {
307
- var h, d = this, m = t, u = r, i = x(o);
344
+ var h, d = this, m = t, u = r, i = x(s);
308
345
  let e;
309
346
  for (h of i) {
310
- var f = u.searchOrCreateSubdir(h);
311
- if (!f.created) {
347
+ var g = u.searchOrCreateSubdir(h);
348
+ if (!g.created) {
312
349
  d._action_createDir({
313
- item: f
350
+ item: g
314
351
  });
315
- for (var g of e = e || m.fileList) {
352
+ for (var f of e = e || m.fileList) {
316
353
  var {
317
- fileContent: g,
354
+ fileContent: f,
318
355
  name: C
319
- } = g;
320
- null != g && E(d, f, h, C, void 0, g);
356
+ } = f;
357
+ null != f && E(d, g, h, C, void 0, f);
321
358
  }
322
359
  }
323
360
  }
@@ -330,7 +367,7 @@ ${r}
330
367
  item: e,
331
368
  indexPropPath: r
332
369
  } = e, e = this.qyCache.getIndexDir(e);
333
- e && ((i = e.getFile(L)) ? (t = i.qyIndexPropTree, this._action_insert({
370
+ e && ((i = e.getFile(b)) ? (t = i.qyIndexPropTree, this._action_insert({
334
371
  item: i,
335
372
  content: {
336
373
  [p(r)]: O
@@ -352,7 +389,7 @@ ${r}
352
389
  parentDir: r,
353
390
  name: n
354
391
  } = i;
355
- return i.created = !1, b(this, e), t || P(this, r, y.R, r.fileMapKey, n),
392
+ return i.created = !1, N(this, e), t || I(this, r, _.R, r.fileMapKey, n),
356
393
  !0;
357
394
  }
358
395
  _action_delDir(e) {
@@ -364,17 +401,17 @@ ${r}
364
401
  name: r,
365
402
  subdirMap: n,
366
403
  fileMap: a,
367
- subdirMapKey: s,
368
- fileMapKey: o
404
+ subdirMapKey: o,
405
+ fileMapKey: s
369
406
  } = t;
370
407
  if (a) {
371
- P(this, t, y.D, o);
408
+ I(this, t, _.D, s);
372
409
  for (var l of t.fileList) this._action_delFile({
373
410
  item: l
374
411
  }, !0);
375
412
  }
376
413
  if (n) {
377
- P(this, t, y.D, s);
414
+ I(this, t, _.D, o);
378
415
  for (var c of t.allSubdirs()) {
379
416
  let {
380
417
  subdirMap: e,
@@ -382,19 +419,19 @@ ${r}
382
419
  subdirMapKey: i,
383
420
  fileMapKey: r
384
421
  } = c;
385
- if (e && P(this, c, y.D, i), t) {
386
- P(this, c, y.D, r);
422
+ if (e && I(this, c, _.D, i), t) {
423
+ I(this, c, _.D, r);
387
424
  for (var h of c.fileList) this._action_delFile({
388
425
  item: h
389
426
  }, !0);
390
427
  }
391
- b(this, {
428
+ N(this, {
392
429
  actionName: "delDir",
393
430
  item: c
394
431
  }), c.created = !1;
395
432
  }
396
433
  }
397
- return !!i && (t.created = !1, b(this, e), P(this, i, y.R, i.subdirMapKey, r),
434
+ return !!i && (t.created = !1, N(this, e), I(this, i, _.R, i.subdirMapKey, r),
398
435
  !0);
399
436
  }
400
437
  _action_delContent(e) {
@@ -406,34 +443,58 @@ ${r}
406
443
  oldValue: i,
407
444
  newValue: O
408
445
  }
409
- }), b(this, e), P(this, t, y.D, t.fileContentKey), I(this, t, i), !0);
446
+ }), N(this, e), I(this, t, _.D, t.fileContentKey), P(this, t, i), !0);
410
447
  }
411
448
  _action_insertEmbedding(e) {
412
449
  e.actionName = "insertEmbedding";
413
- var {
414
- item: e,
415
- content: t,
416
- srcFile: i
417
- } = e, i = (this._action_insert({
418
- item: this.qyCache.getOrCreateH2FFile(i.fullPathHash),
419
- content: i.namePath
420
- }), this._action_insert({
421
- item: e,
422
- content: t
423
- }));
424
- return i;
450
+ var t, i, r = this.qyCache, n = r.qyEmbeddings, {
451
+ item: a,
452
+ embedding: o
453
+ } = e, s = o.length, r = r.getOrCreateInfoFile(a), l = r.fileContent;
454
+ let c = !1;
455
+ return r.created && l.length == s ? (t = a.fullPathHash, l = l.idx, i = n.getEmbedding(t, s, l),
456
+ h(o, i) || ((i = n.updateEmbedding(t, o, l)) != l && this._action_insert({
457
+ item: r,
458
+ content: {
459
+ idx: i
460
+ }
461
+ }), c = !0)) : ({
462
+ fullPathHash: t,
463
+ namePath: l
464
+ } = a, i = n.addEmbedding(t, o), this._action_insert({
465
+ item: r,
466
+ content: {
467
+ length: s,
468
+ idx: i,
469
+ namePath: r.created ? void 0 : l
470
+ }
471
+ }), c = !0), c && N(this, e), c;
425
472
  }
426
473
  _action_delEmbedding(e) {
427
474
  e.actionName = "delEmbedding";
475
+ var t = this.qyCache, i = t.qyEmbeddings, r = e.item;
476
+ let n, a;
477
+ var o, t = t.getInfoFile(r);
478
+ if (t && (o = t.fileContent, o) && (n = o.length, a = o.idx), i.delEmbedding(r.fullPathHash, n, a),
479
+ t) return this._action_delFile({
480
+ item: t
481
+ }), N(this, e), !0;
482
+ }
483
+ _action_put(e) {
484
+ e.actionName = "put";
428
485
  var {
429
- item: e,
430
- srcFile: t
431
- } = e, e = this._action_delFile({
432
- item: e
486
+ item: t,
487
+ content: i
488
+ } = e;
489
+ if (null == i) return F.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
490
+ !1;
491
+ t.created || this._action_createFile({
492
+ item: t
433
493
  });
434
- return e && this._action_delFile({
435
- item: this.qyCache.getOrCreateH2FFile(t.fullPathHash)
436
- }), e;
494
+ var r = t.fileContentKey;
495
+ return I(this, t, _.M, r, {
496
+ $rpl: i
497
+ }), N(this, e), t.fileContent = i, !0;
437
498
  }
438
499
  _action_insert(e) {
439
500
  e.actionName = "insert";
@@ -450,15 +511,15 @@ ${r}
450
511
  item: t
451
512
  });
452
513
  }
453
- var n, a, r = l(t.fileContent, i), {
514
+ var n, a, r = s(t.fileContent, i), {
454
515
  merged: i,
455
- delta: s
516
+ delta: o
456
517
  } = r;
457
- return !!s && ({
458
- oldValue: s,
518
+ return !!o && ({
519
+ oldValue: o,
459
520
  newValue: n
460
- } = s, !!n) && (a = t.fileContentKey, null == i ? P(this, t, y.D, a) : P(this, t, y.M, a, n),
461
- Object.assign(e, r), b(this, e), t.fileContent = i, I(this, t, s, n, i),
521
+ } = o, !!n) && (a = t.fileContentKey, null == i ? I(this, t, _.D, a) : I(this, t, _.M, a, n),
522
+ Object.assign(e, r), N(this, e), t.fileContent = i, P(this, t, o, n, i),
462
523
  !0);
463
524
  }
464
525
  _action_createFile(e) {
@@ -469,7 +530,7 @@ ${r}
469
530
  }), Object.assign(i, {
470
531
  created: !0,
471
532
  fileContentLoaded: !0
472
- }), b(this, e), P(this, t, y.A, t.fileMapKey, i.name), !0);
533
+ }), N(this, e), I(this, t, _.A, t.fileMapKey, i.name), !0);
473
534
  }
474
535
  _action_createDir(e) {
475
536
  e.actionName = "createDir";
@@ -481,12 +542,12 @@ ${r}
481
542
  created: !0,
482
543
  subdirMapLoaded: !0,
483
544
  fileMapLoaded: !0
484
- }), b(this, {
545
+ }), N(this, {
485
546
  actionName: "createDir",
486
547
  item: e
487
548
  });
488
549
  var r = e.parentDir;
489
- P(this, r, y.A, r.subdirMapKey, e.name);
550
+ I(this, r, _.A, r.subdirMapKey, e.name);
490
551
  }
491
552
  return !0;
492
553
  }
@@ -499,7 +560,7 @@ ${r}
499
560
  parentDir: r,
500
561
  name: n
501
562
  } = e;
502
- return !!r && null != (i = S(i, !0, m())) && (t = this.qyCache, r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"),
563
+ return !!r && null != (i = S(i, !0, d())) && (t = this.qyCache, r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"),
503
564
  (r = this._action_insert({
504
565
  item: r,
505
566
  content: {
@@ -521,7 +582,7 @@ ${r}
521
582
  content: {
522
583
  [n]: O
523
584
  }
524
- })) && (d(r.fileContent) && this._action_delFile({
585
+ })) && (m(r.fileContent) && this._action_delFile({
525
586
  item: r
526
587
  }), i || t.unmonitorItemExpire(e)), n);
527
588
  }
@@ -531,14 +592,14 @@ ${r}
531
592
  item: t,
532
593
  expireInfoObj: i,
533
594
  isMilliSecond: r
534
- } = e, n = m();
535
- var e = j(i, e => S(e, r, n)), a = this.qyCache, s = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), s = this._action_insert({
536
- item: s,
595
+ } = e, n = d();
596
+ var e = j(i, e => S(e, r, n)), a = this.qyCache, o = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), o = this._action_insert({
597
+ item: o,
537
598
  content: {
538
599
  ...e
539
600
  }
540
601
  });
541
- return s && a.monitorContentExpire(t, e), s;
602
+ return o && a.monitorContentExpire(t, e), o;
542
603
  }
543
604
  _action_removeContentExpire(e) {
544
605
  e.actionName = "removeContentExpire";
@@ -547,25 +608,22 @@ ${r}
547
608
  expireInfoObj: i,
548
609
  infoFileOnly: r
549
610
  } = e, n = this.qyCache, a = n.getExpireInfoFile(e.fullPathHash, "c");
550
- return !!a && (i = f(i) ? Object.fromEntries(i.map(e => [ e, O ])) : j(i, e => e ? O : void 0),
611
+ return !!a && (i = g(i) ? Object.fromEntries(i.map(e => [ e, O ])) : j(i, e => e ? O : void 0),
551
612
  (t = this._action_insert({
552
613
  item: a,
553
614
  content: i
554
- })) && (d(a.fileContent) && this._action_delFile({
615
+ })) && (m(a.fileContent) && this._action_delFile({
555
616
  item: a
556
617
  }), r || n.unmonitorContentExpire(e, i)), t);
557
618
  }
558
619
  }
559
620
 
560
- function N(e, t, i, r) {
561
- return e.actionQueue.push({
562
- actionName: t,
563
- item: i,
564
- ...r
565
- }), e;
621
+ function q(e, t, i) {
622
+ return e.running ? t.call(e, i) : (i.actionFun = t, e.actionQueue.push(i)),
623
+ e;
566
624
  }
567
625
 
568
- function b(e, t) {
626
+ function N(e, t) {
569
627
  var {
570
628
  changeList: e,
571
629
  fileLogLevel: i
@@ -589,46 +647,57 @@ function b(e, t) {
589
647
  })(t, i)), e.push(t);
590
648
  }
591
649
 
592
- function P(e, t, i, r, n = void 0) {
650
+ function I(e, t, i, r, n = void 0) {
593
651
  var {
594
652
  qyAclCmdGenerator: e,
595
653
  qyCache: a,
596
- syncList: s,
597
- changeId: o
654
+ syncList: o,
655
+ changeId: s
598
656
  } = e;
599
- e.pushCmd(i, r, n), r.startsWith("d") ? t.dChangeId = o : r.startsWith("f") ? t.fChangeId = o : t.cChangeId = o,
600
- a && a.qyKVData.removeKey(r) && s.push(r, t);
657
+ e.pushCmd(i, r, n), r.startsWith("d") ? t.dChangeId = s : r.startsWith("f") ? t.fChangeId = s : t.cChangeId = s,
658
+ a && a.qyKVData.removeKey(r) && o.push(r, t);
601
659
  }
602
660
 
603
- function I(e, t, i, r = void 0, n = void 0) {
661
+ function P(e, t, i, r = void 0, n = void 0) {
604
662
  var {
605
663
  underHiddenFolder: t,
606
664
  name: a,
607
- parentDir: s
665
+ parentDir: o
608
666
  } = t;
609
667
  if (!t) {
610
- var o = e.qyCache.getIndexDir(s);
611
- if (o) {
612
- t = o.getFile(L);
613
- if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) E(e, o.searchOrCreateSubdir(l), l, a, i, r, n);
668
+ var s = e.qyCache.getIndexDir(o);
669
+ if (s) {
670
+ t = s.getFile(b);
671
+ if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) E(e, s.searchOrCreateSubdir(l), l, a, i, r, n);
614
672
  }
615
673
  }
616
674
  }
617
675
 
618
- function E(t, e, i, r, n, a, s = void 0) {
619
- e = v(e, i, r, n, a, s);
676
+ function E(t, e, i, r, n, a, o = void 0) {
677
+ e = v(e, i, n, a, o);
620
678
  if (e) {
621
- var o, l, c, {
679
+ var s, l, c, {
622
680
  toAddFileList: i,
623
- toDelFileList: r
681
+ toDelFileList: n
624
682
  } = e;
625
- for (o of i) t._action_createFile({
626
- item: o
627
- });
628
- for (l of r) t._action_delFile({
629
- item: l
630
- });
631
- for (c of r) {
683
+ for (s of i) {
684
+ var h = s.fileContent ?? {};
685
+ h[r] = 1, t._action_put({
686
+ item: s,
687
+ content: h
688
+ });
689
+ }
690
+ for (l of n) {
691
+ var d = l.fileContent;
692
+ null != d && Object.hasOwn(d, r) && (delete d[r], t._action_put({
693
+ item: l,
694
+ content: d
695
+ }));
696
+ }
697
+ for (c of n) if (m(c.fileContent)) {
698
+ t._action_delFile({
699
+ item: c
700
+ });
632
701
  let e = c.parentDir;
633
702
  for (;e.created && !e.isHiddenFolder && e.isEmpty; ) t._action_delDir({
634
703
  item: e
@@ -637,7 +706,7 @@ function E(t, e, i, r, n, a, s = void 0) {
637
706
  }
638
707
  }
639
708
 
640
- class H {
709
+ class A {
641
710
  maxLength;
642
711
  actionQueue;
643
712
  nextPos;
@@ -666,30 +735,32 @@ class H {
666
735
  }
667
736
 
668
737
  function j(e, t = void 0, i = [], r = {}) {
669
- if (h(e)) {
738
+ if (c(e)) {
670
739
  var n = t ? t(e) : e;
671
740
  null != n && (r[JSON.stringify(i)] = n);
672
741
  } else {
673
- var a, s = i.length;
674
- for (a in e) i.push(a), j(e[a], t, i, r), i.length = s;
742
+ var a, o = i.length;
743
+ for (a in e) i.push(a), j(e[a], t, i, r), i.length = o;
675
744
  }
676
745
  return r;
677
746
  }
678
747
 
679
748
  function S(e, t, i) {
680
- return a(e) ? (t ? e : 1e3 * e) + i : c(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !u(e) || (t = e.getTime()) <= i ? void 0 : t;
749
+ return a(e) ? (t ? e : 1e3 * e) + i : l(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !u(e) || (t = e.getTime()) <= i ? void 0 : t;
681
750
  }
682
751
 
683
752
  function T(e, t, i, r, n) {
684
- var a = e.qyCache, r = (c(t) && (t = s(t)), "f" == r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
685
- return N(e, "expireItem", r, {
753
+ var a = e.qyCache, r = (l(t) && (t = o(t)), "f" == r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
754
+ return q(e, e._action_expireItem, {
755
+ item: r,
686
756
  milliSecond: i
687
757
  });
688
758
  }
689
759
 
690
760
  function M(e, t, i, r, n) {
691
- var a = e.qyCache, i = (c(t) && (t = s(t)), "f" == i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
692
- return N(e, "removeItemExpire", i, {
761
+ var a = e.qyCache, i = (l(t) && (t = o(t)), "f" == i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
762
+ return q(e, e._action_removeItemExpire, {
763
+ item: i,
693
764
  infoFileOnly: r
694
765
  });
695
766
  }