datafolder 1.0.29 → 1.0.30
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/airbnb.js +3 -3
- package/scripts/airbnb2.js +3 -3
- package/scripts/airbnb_queries.js +6 -6
- package/scripts/convertBinFiles.js +2 -2
- package/scripts/fastify.js +2 -1
- package/scripts/flights.js +1 -1
- package/scripts/flights2.js +1 -1
- package/scripts/flights2_queries.js +6 -6
- package/scripts/flights_queries.js +6 -6
- package/src/QyAcl.js +85 -89
- package/src/QyBatch.js +100 -111
- package/src/QyBinWriter.js +11 -14
- package/src/QyBinaryHeap.js +2 -2
- package/src/QyCD.js +1 -1
- package/src/QyCompressor.js +2 -2
- package/src/QyDir.js +9 -9
- package/src/QyEmbeddingWriter.js +1 -1
- package/src/QyEmbeddings.js +18 -18
- package/src/QyExpire.js +2 -4
- package/src/QyExpireInfo.js +32 -32
- package/src/QyExpire_Worker.js +2 -5
- package/src/QyFile.js +67 -67
- package/src/QyFileContentUtils.js +92 -92
- package/src/QyFileLogger.js +1 -1
- package/src/QyIndex.js +113 -113
- package/src/QyIndexPropTree.js +5 -5
- package/src/QyIntersectNode.js +8 -10
- package/src/QyItem.js +28 -28
- package/src/QyKVData.js +40 -45
- package/src/QyKVDataCleaner_Worker.js +1 -1
- package/src/QyKVDataSaver_Worker.js +5 -7
- package/src/QyMessageWorker.js +1 -1
- package/src/QyMessager.js +2 -2
- package/src/QySaver.js +20 -20
- package/src/QySnapshotCompactor_Worker.js +6 -15
- package/src/QySnapshotSaver_Worker.js +1 -1
- package/src/QySnapshots.js +78 -88
- package/src/QyStructure.js +1 -1
- package/src/QyTrigger.js +3 -8
- package/src/QyUtils.d.ts +0 -4
- package/src/QyUtils.js +69 -97
- package/src/hackernews.js +77 -59
- package/src/rpc/getFileContent.js +4 -3
- package/src/rpc/getSubItems.js +6 -4
- package/src/simulate.js +4 -4
- package/src/simulate2.js +3 -3
- package/src/soc_pokec.js +1 -1
- package/test/testQyAQL.js +23 -23
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 {
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
getSuffix as g,
|
|
14
14
|
SpecialFilePaths as e,
|
|
15
15
|
toSingleName as p,
|
|
16
|
-
isSimpleType as
|
|
16
|
+
isSimpleType as h,
|
|
17
17
|
isEmptyObj as d,
|
|
18
18
|
isNumber as r,
|
|
19
19
|
getNowRounded as m,
|
|
@@ -80,22 +80,22 @@ class O extends t {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
createDir(e, t = this.currentDir) {
|
|
83
|
-
return l(e) && (e = o(e)),
|
|
83
|
+
return l(e) && (e = o(e)), P(this, this._action_createDir, {
|
|
84
84
|
item: this.qyCache.getOrCreateDir(e, t)
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
delDir(e, t = this.currentDir) {
|
|
88
|
-
return l(e) && (e = o(e)),
|
|
88
|
+
return l(e) && (e = o(e)), P(this, this._action_delDir, {
|
|
89
89
|
item: this.qyCache.getOrCreateDir(e, t).ensureAllLoaded()
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
createFile(e, t = this.currentDir) {
|
|
93
|
-
return l(e) && (e = o(e)),
|
|
93
|
+
return l(e) && (e = o(e)), P(this, this._action_createFile, {
|
|
94
94
|
item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
delFile(e, t = this.currentDir) {
|
|
98
|
-
return l(e) && (e = o(e)),
|
|
98
|
+
return l(e) && (e = o(e)), P(this, this._action_delFile, {
|
|
99
99
|
item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
|
|
100
100
|
});
|
|
101
101
|
}
|
|
@@ -103,18 +103,18 @@ class O extends t {
|
|
|
103
103
|
return this.expireFileM(e, 1e3 * t, i);
|
|
104
104
|
}
|
|
105
105
|
expireFileM(e, t, i = this.currentDir) {
|
|
106
|
-
return
|
|
106
|
+
return T(this, e, t, "f", i);
|
|
107
107
|
}
|
|
108
108
|
expireDir(e, t, i = this.currentDir) {
|
|
109
109
|
return this.expireDirM(e, 1e3 * t, i);
|
|
110
110
|
}
|
|
111
111
|
expireDirM(e, t, i = this.currentDir) {
|
|
112
|
-
return
|
|
112
|
+
return T(this, e, t, "d", i);
|
|
113
113
|
}
|
|
114
114
|
expireContent(e, t, i, r = this.currentDir) {
|
|
115
115
|
l(e) && (e = o(e));
|
|
116
116
|
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
117
|
-
return
|
|
117
|
+
return P(this, this._action_expireContent, {
|
|
118
118
|
item: e,
|
|
119
119
|
expireInfoObj: t,
|
|
120
120
|
isMilliSecond: i
|
|
@@ -124,15 +124,15 @@ class O extends t {
|
|
|
124
124
|
return this.expireContent(e, t, !0, i);
|
|
125
125
|
}
|
|
126
126
|
removeFileExpire(e, t = !1, i = this.currentDir) {
|
|
127
|
-
return
|
|
127
|
+
return j(this, e, "f", t, i);
|
|
128
128
|
}
|
|
129
129
|
removeDirExpire(e, t = !1, i = this.currentDir) {
|
|
130
|
-
return
|
|
130
|
+
return j(this, e, "d", t, i);
|
|
131
131
|
}
|
|
132
132
|
removeContentExpire(e, t, i = !1, r = this.currentDir) {
|
|
133
133
|
l(e) && (e = o(e));
|
|
134
134
|
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
135
|
-
return
|
|
135
|
+
return P(this, this._action_removeContentExpire, {
|
|
136
136
|
item: e,
|
|
137
137
|
expireInfoObj: t,
|
|
138
138
|
infoFileOnly: i
|
|
@@ -141,7 +141,7 @@ class O extends t {
|
|
|
141
141
|
createIndex(e, t, i = this.currentDir) {
|
|
142
142
|
l(e) && (e = o(e)), u(t) || (t = [ t ]);
|
|
143
143
|
e = this.qyCache.getOrCreateDir(e, i);
|
|
144
|
-
return
|
|
144
|
+
return P(this, this._action_createIndex, {
|
|
145
145
|
item: e,
|
|
146
146
|
indexPropPathList: t
|
|
147
147
|
});
|
|
@@ -149,7 +149,7 @@ class O extends t {
|
|
|
149
149
|
delIndex(e, t, i = this.currentDir) {
|
|
150
150
|
l(e) && (e = o(e));
|
|
151
151
|
e = this.qyCache.getOrCreateDir(e, i);
|
|
152
|
-
return
|
|
152
|
+
return P(this, this._action_delIndex, {
|
|
153
153
|
item: e,
|
|
154
154
|
indexPropPath: t
|
|
155
155
|
});
|
|
@@ -157,7 +157,7 @@ class O extends t {
|
|
|
157
157
|
insert(e, t, i = !0, r = !1, n = this.currentDir) {
|
|
158
158
|
l(e) && (e = o(e));
|
|
159
159
|
e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
|
|
160
|
-
return t = i ||
|
|
160
|
+
return t = i || h(t) ? t : structuredClone(t), P(this, this._action_insert, {
|
|
161
161
|
item: e,
|
|
162
162
|
content: t,
|
|
163
163
|
noCreate: r
|
|
@@ -166,14 +166,14 @@ class O extends t {
|
|
|
166
166
|
insertEmbedding(e, t, i = this.currentDir) {
|
|
167
167
|
var r = this.qyCache, r = (f(t) || (t = new Float32Array(t)), l(e) && (e = o(e)),
|
|
168
168
|
r.getOrCreateFile(e, i));
|
|
169
|
-
return
|
|
169
|
+
return P(this, this._action_insertEmbedding, {
|
|
170
170
|
item: r,
|
|
171
171
|
embedding: t
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
delEmbedding(e, t = this.currentDir) {
|
|
175
175
|
var i = this.qyCache, i = (l(e) && (e = o(e)), i.getOrCreateFile(e, t));
|
|
176
|
-
return
|
|
176
|
+
return P(this, this._action_delEmbedding, {
|
|
177
177
|
item: i
|
|
178
178
|
});
|
|
179
179
|
}
|
|
@@ -183,14 +183,14 @@ class O extends t {
|
|
|
183
183
|
delContent(e, t = this.currentDir) {
|
|
184
184
|
l(e) && (e = o(e));
|
|
185
185
|
e = this.qyCache.getOrCreateFile(e, t).ensureLoaded();
|
|
186
|
-
return
|
|
186
|
+
return P(this, this._action_delContent, {
|
|
187
187
|
item: e
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
insertTrigger(e, t, i, r) {
|
|
191
191
|
l(t) && (t = o(t)), i = n(i);
|
|
192
192
|
e = this.qyCache.getOrCreateTriggerFile(e);
|
|
193
|
-
return
|
|
193
|
+
return P(this, this._action_insertTrigger, {
|
|
194
194
|
item: e,
|
|
195
195
|
fileNamePath: t,
|
|
196
196
|
propNamePathList: i,
|
|
@@ -198,19 +198,19 @@ class O extends t {
|
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
removeTrigger(e) {
|
|
201
|
-
return
|
|
201
|
+
return P(this, this._action_removeTrigger, {
|
|
202
202
|
item: this.qyCache.getOrCreateTriggerFile(e)
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
insertRpc(e, t) {
|
|
206
206
|
e = this.qyCache.getOrCreateRpcFile(e);
|
|
207
|
-
return
|
|
207
|
+
return P(this, this._action_insertRpc, {
|
|
208
208
|
item: e,
|
|
209
209
|
modCode: t
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
removeRpc(e) {
|
|
213
|
-
return
|
|
213
|
+
return P(this, this._action_removeRpc, {
|
|
214
214
|
item: this.qyCache.getOrCreateRpcFile(e)
|
|
215
215
|
});
|
|
216
216
|
}
|
|
@@ -221,7 +221,7 @@ class O extends t {
|
|
|
221
221
|
fileLogLevel: r,
|
|
222
222
|
qyCache: n
|
|
223
223
|
} = this;
|
|
224
|
-
if (t || 0
|
|
224
|
+
if (t || 0 === i.length) return 0;
|
|
225
225
|
this.running = !0;
|
|
226
226
|
var a, t = this.changeId = n.increaseChangeId();
|
|
227
227
|
for (a of i) a.actionFun.call(this, a);
|
|
@@ -231,16 +231,16 @@ class O extends t {
|
|
|
231
231
|
qyAclCmdGenerator: o,
|
|
232
232
|
qyCmdObjHistory: s,
|
|
233
233
|
syncList: l
|
|
234
|
-
} = this,
|
|
235
|
-
if (0
|
|
236
|
-
var
|
|
234
|
+
} = this, h = i.length;
|
|
235
|
+
if (0 === h) return n.decreaseChangeId(), 0;
|
|
236
|
+
var c = g(h), o = o.takeCmdArgAsListObj();
|
|
237
237
|
let d;
|
|
238
238
|
0 < r && (r = i.map(({
|
|
239
239
|
logStr: e
|
|
240
|
-
}) => e).join("\n"), d = new Date().toISOString() + `: ${
|
|
240
|
+
}) => e).join("\n"), d = new Date().toISOString() + `: ${h} change${c}:
|
|
241
241
|
${r}
|
|
242
242
|
`);
|
|
243
|
-
var m, u,
|
|
243
|
+
var m, u, h = n.save(t, o, d, (e => {
|
|
244
244
|
var t = e.syncList, i = t.length;
|
|
245
245
|
for (let e = 0; e < i; e += 2) {
|
|
246
246
|
var r, n = e + 1, a = t[e], o = t[n];
|
|
@@ -248,7 +248,7 @@ ${r}
|
|
|
248
248
|
t[n] = 0 < r.length ? r : void 0) : t[n] = o.fileContent;
|
|
249
249
|
}
|
|
250
250
|
if (0 < i) return t;
|
|
251
|
-
})(this), e),
|
|
251
|
+
})(this), e), c = (l.length = 0, s.push(o), i.filter(({
|
|
252
252
|
item: e,
|
|
253
253
|
delta: t
|
|
254
254
|
}) => t && 0 < e.triggerNodes?.length));
|
|
@@ -256,8 +256,8 @@ ${r}
|
|
|
256
256
|
for ({
|
|
257
257
|
item: m,
|
|
258
258
|
delta: u
|
|
259
|
-
} of
|
|
260
|
-
return e ?
|
|
259
|
+
} of c) for (var f of m.triggerNodes) f.checkTrigger(m, u);
|
|
260
|
+
return e ? h : t;
|
|
261
261
|
}
|
|
262
262
|
getTopHistoryCmdObj() {
|
|
263
263
|
return this.qyCmdObjHistory.top();
|
|
@@ -276,7 +276,7 @@ ${r}
|
|
|
276
276
|
item: e,
|
|
277
277
|
content: o
|
|
278
278
|
}));
|
|
279
|
-
return e && (o = this.qyCache, a && !
|
|
279
|
+
return e && (o = this.qyCache, a && !c(a, t) && o.removeTriggerFromTree(n, a),
|
|
280
280
|
o.insertTriggerToTree(n, t, i, r)), e;
|
|
281
281
|
}
|
|
282
282
|
_action_removeTrigger(e) {
|
|
@@ -319,19 +319,19 @@ ${r}
|
|
|
319
319
|
item: n
|
|
320
320
|
}), n), s = [], l = {};
|
|
321
321
|
for (e of i) {
|
|
322
|
-
var
|
|
323
|
-
a && a[
|
|
322
|
+
var h = p(e);
|
|
323
|
+
a && a[h] || (s.push(e), l[h] = 1, o.insert(e));
|
|
324
324
|
}
|
|
325
|
-
if (0
|
|
325
|
+
if (0 !== s.length) {
|
|
326
326
|
x.log(`Creating index ${JSON.stringify(s)} for ` + t.fullPath), this._action_insert({
|
|
327
327
|
item: n,
|
|
328
328
|
content: l
|
|
329
329
|
});
|
|
330
330
|
{
|
|
331
|
-
var
|
|
331
|
+
var c, d = this, m = t, u = r, i = y(s);
|
|
332
332
|
let e;
|
|
333
|
-
for (
|
|
334
|
-
var f = u.searchOrCreateSubdir(
|
|
333
|
+
for (c of i) {
|
|
334
|
+
var f = u.searchOrCreateSubdir(c);
|
|
335
335
|
if (!f.created) {
|
|
336
336
|
d._action_createDir({
|
|
337
337
|
item: f
|
|
@@ -341,7 +341,7 @@ ${r}
|
|
|
341
341
|
fileContent: g,
|
|
342
342
|
name: C
|
|
343
343
|
} = g;
|
|
344
|
-
|
|
344
|
+
void 0 !== g && N(d, f, c, C, void 0, g);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
}
|
|
@@ -365,14 +365,14 @@ ${r}
|
|
|
365
365
|
e.actionName = "delFile";
|
|
366
366
|
var i = e.item;
|
|
367
367
|
if (!i.created) return !1;
|
|
368
|
-
|
|
368
|
+
void 0 !== i.fileContent && this._action_delContent({
|
|
369
369
|
item: i
|
|
370
370
|
});
|
|
371
371
|
var {
|
|
372
372
|
parentDir: r,
|
|
373
373
|
name: n
|
|
374
374
|
} = i;
|
|
375
|
-
return i.created = !1,
|
|
375
|
+
return i.created = !1, L(this, e), t || q(this, r, C.R, r.fileMapKey, n),
|
|
376
376
|
!0;
|
|
377
377
|
}
|
|
378
378
|
_action_delDir(e) {
|
|
@@ -388,45 +388,42 @@ ${r}
|
|
|
388
388
|
fileMapKey: s
|
|
389
389
|
} = t;
|
|
390
390
|
if (a) {
|
|
391
|
-
|
|
391
|
+
q(this, t, C.D, s);
|
|
392
392
|
for (var l of t.fileList) this._action_delFile({
|
|
393
393
|
item: l
|
|
394
394
|
}, !0);
|
|
395
395
|
}
|
|
396
396
|
if (n) {
|
|
397
|
-
|
|
398
|
-
for (var
|
|
397
|
+
q(this, t, C.D, o);
|
|
398
|
+
for (var h of t.allSubdirs()) {
|
|
399
399
|
let {
|
|
400
400
|
subdirMap: e,
|
|
401
401
|
fileMap: t,
|
|
402
402
|
subdirMapKey: i,
|
|
403
403
|
fileMapKey: r
|
|
404
|
-
} =
|
|
405
|
-
if (e &&
|
|
406
|
-
|
|
407
|
-
for (var
|
|
408
|
-
item:
|
|
404
|
+
} = h;
|
|
405
|
+
if (e && q(this, h, C.D, i), t) {
|
|
406
|
+
q(this, h, C.D, r);
|
|
407
|
+
for (var c of h.fileList) this._action_delFile({
|
|
408
|
+
item: c
|
|
409
409
|
}, !0);
|
|
410
410
|
}
|
|
411
|
-
|
|
411
|
+
L(this, {
|
|
412
412
|
actionName: "delDir",
|
|
413
|
-
item:
|
|
414
|
-
}),
|
|
413
|
+
item: h
|
|
414
|
+
}), h.created = !1;
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
return !!i && (t.created = !1,
|
|
417
|
+
return !!i && (t.created = !1, L(this, e), q(this, i, C.R, i.subdirMapKey, r),
|
|
418
418
|
!0);
|
|
419
419
|
}
|
|
420
420
|
_action_delContent(e) {
|
|
421
421
|
e.actionName = "delContent";
|
|
422
422
|
var t = e.item, i = t.fileContent;
|
|
423
|
-
return
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
newValue: null
|
|
428
|
-
}
|
|
429
|
-
}), P(this, e), L(this, t, C.D, t.fileContentKey), q(this, t, i), !0);
|
|
423
|
+
return void 0 !== i && (t.fileContent = void 0, e.content = i, e.delta = {
|
|
424
|
+
oldValue: i,
|
|
425
|
+
newValue: null
|
|
426
|
+
}, L(this, e), q(this, t, C.D, t.fileContentKey), b(this, t, i), !0);
|
|
430
427
|
}
|
|
431
428
|
_action_insertEmbedding(e) {
|
|
432
429
|
e.actionName = "insertEmbedding";
|
|
@@ -434,10 +431,10 @@ ${r}
|
|
|
434
431
|
item: a,
|
|
435
432
|
embedding: o
|
|
436
433
|
} = e, s = o.length, r = r.getOrCreateInfoFile(a), l = r.fileContent;
|
|
437
|
-
let
|
|
438
|
-
return r.created && l.length
|
|
439
|
-
|
|
440
|
-
|
|
434
|
+
let h = !1;
|
|
435
|
+
return r.created && l.length === s ? (t = a.fullPathHash, l = l.idx, i = n.getEmbedding(t, s, l),
|
|
436
|
+
c(o, i) || ((i = n.updateEmbedding(t, o, l)) !== l && this._setProp(r, "idx", i),
|
|
437
|
+
h = !0)) : ({
|
|
441
438
|
fullPathHash: t,
|
|
442
439
|
namePath: l
|
|
443
440
|
} = a, i = n.addEmbedding(t, o), this._action_insert({
|
|
@@ -447,7 +444,7 @@ ${r}
|
|
|
447
444
|
idx: i,
|
|
448
445
|
namePath: r.created ? void 0 : l
|
|
449
446
|
}
|
|
450
|
-
}),
|
|
447
|
+
}), h = !0), h && L(this, e), h;
|
|
451
448
|
}
|
|
452
449
|
_action_delEmbedding(e) {
|
|
453
450
|
e.actionName = "delEmbedding";
|
|
@@ -457,7 +454,7 @@ ${r}
|
|
|
457
454
|
if (t && (o = t.fileContent, o) && (n = o.length, a = o.idx), i.delEmbedding(r.fullPathHash, n, a),
|
|
458
455
|
t) return this._action_delFile({
|
|
459
456
|
item: t
|
|
460
|
-
}),
|
|
457
|
+
}), L(this, e), !0;
|
|
461
458
|
}
|
|
462
459
|
_action_put(e) {
|
|
463
460
|
e.actionName = "put";
|
|
@@ -465,13 +462,13 @@ ${r}
|
|
|
465
462
|
item: t,
|
|
466
463
|
content: i
|
|
467
464
|
} = e;
|
|
468
|
-
if (
|
|
465
|
+
if (void 0 === i) return x.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
|
|
469
466
|
!1;
|
|
470
467
|
t.created || this._action_createFile({
|
|
471
468
|
item: t
|
|
472
469
|
});
|
|
473
470
|
var r = t.fileContentKey;
|
|
474
|
-
return i.$rpl = 1,
|
|
471
|
+
return i.$rpl = 1, q(this, t, C.M, r, i), L(this, e), t.fileContent = i,
|
|
475
472
|
!0;
|
|
476
473
|
}
|
|
477
474
|
_setProp(e, t, i) {
|
|
@@ -482,9 +479,9 @@ ${r}
|
|
|
482
479
|
} = e, r = (r || this._action_createFile({
|
|
483
480
|
item: e
|
|
484
481
|
}), a ? a[t] : void 0);
|
|
485
|
-
return null === i ?
|
|
482
|
+
return null === i ? void 0 !== a && delete a[t] : void 0 !== a ? a[t] = i : e.fileContent = {
|
|
486
483
|
[t]: i
|
|
487
|
-
},
|
|
484
|
+
}, q(this, e, C.M, n, t, i), r;
|
|
488
485
|
}
|
|
489
486
|
_action_insert(e) {
|
|
490
487
|
e.actionName = "insert";
|
|
@@ -497,7 +494,7 @@ ${r}
|
|
|
497
494
|
merged: a,
|
|
498
495
|
delta: o
|
|
499
496
|
} = e;
|
|
500
|
-
if (
|
|
497
|
+
if (void 0 === o && void 0 === r) return x.warn(`Saving undefined to ${i.fullPath}. Not making any change.`),
|
|
501
498
|
!1;
|
|
502
499
|
if (!i.created) {
|
|
503
500
|
if (n) return !1;
|
|
@@ -505,25 +502,21 @@ ${r}
|
|
|
505
502
|
item: i
|
|
506
503
|
});
|
|
507
504
|
}
|
|
508
|
-
return
|
|
509
|
-
o = n.delta),
|
|
505
|
+
return void 0 === a && void 0 === o && (n = s(i.fileContent, r), a = n.merged,
|
|
506
|
+
o = n.delta), void 0 !== o && ({
|
|
510
507
|
oldValue: r,
|
|
511
508
|
newValue: n
|
|
512
|
-
} = o, t = i.fileContentKey,
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
delta: o
|
|
516
|
-
}), P(this, e), i.fileContent = a, q(this, i, r, n, a), !0);
|
|
509
|
+
} = o, t = i.fileContentKey, void 0 === a ? q(this, i, C.D, t) : q(this, i, C.M, t, n),
|
|
510
|
+
e.merged = a, e.delta = o, L(this, e), i.fileContent = a, b(this, i, r, n, a),
|
|
511
|
+
!0);
|
|
517
512
|
}
|
|
518
513
|
_action_createFile(e) {
|
|
519
514
|
e.actionName = "createFile";
|
|
520
515
|
var t, i = e.item;
|
|
521
516
|
return !i.created && (t = i.parentDir, this._action_createDir({
|
|
522
517
|
item: t
|
|
523
|
-
}),
|
|
524
|
-
|
|
525
|
-
fileContentLoaded: !0
|
|
526
|
-
}), P(this, e), L(this, t, C.A, t.fileMapKey, i.name), !0);
|
|
518
|
+
}), i.created = !0, i.fileContentLoaded = !0, L(this, e), q(this, t, C.A, t.fileMapKey, i.name),
|
|
519
|
+
!0);
|
|
527
520
|
}
|
|
528
521
|
_action_createDir(e) {
|
|
529
522
|
e.actionName = "createDir";
|
|
@@ -531,16 +524,12 @@ ${r}
|
|
|
531
524
|
if (t.created) return !1;
|
|
532
525
|
for (var i = []; !t.created; ) i.push(t), t = t.parentDir;
|
|
533
526
|
for (let e of i.reverse()) {
|
|
534
|
-
|
|
535
|
-
created: !0,
|
|
536
|
-
subdirMapLoaded: !0,
|
|
537
|
-
fileMapLoaded: !0
|
|
538
|
-
}), P(this, {
|
|
527
|
+
e.created = !0, e.subdirMapLoaded = !0, e.fileMapLoaded = !0, L(this, {
|
|
539
528
|
actionName: "createDir",
|
|
540
529
|
item: e
|
|
541
530
|
});
|
|
542
531
|
var r = e.parentDir;
|
|
543
|
-
|
|
532
|
+
q(this, r, C.A, r.subdirMapKey, e.name);
|
|
544
533
|
}
|
|
545
534
|
return !0;
|
|
546
535
|
}
|
|
@@ -553,7 +542,7 @@ ${r}
|
|
|
553
542
|
parentDir: r,
|
|
554
543
|
name: n
|
|
555
544
|
} = e;
|
|
556
|
-
return !!r &&
|
|
545
|
+
return !!r && void 0 !== (i = S(i, !0, m())) && (t = this.qyCache, r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"),
|
|
557
546
|
(r = this._action_insert({
|
|
558
547
|
item: r,
|
|
559
548
|
content: {
|
|
@@ -586,7 +575,7 @@ ${r}
|
|
|
586
575
|
expireInfoObj: i,
|
|
587
576
|
isMilliSecond: r
|
|
588
577
|
} = e, n = m();
|
|
589
|
-
var e = E(i, e =>
|
|
578
|
+
var e = E(i, e => S(e, r, n)), a = this.qyCache, o = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), o = this._action_insert({
|
|
590
579
|
item: o,
|
|
591
580
|
content: {
|
|
592
581
|
...e
|
|
@@ -611,12 +600,12 @@ ${r}
|
|
|
611
600
|
}
|
|
612
601
|
}
|
|
613
602
|
|
|
614
|
-
function
|
|
603
|
+
function P(e, t, i) {
|
|
615
604
|
return e.running ? t.call(e, i) : (i.actionFun = t, e.actionQueue.push(i)),
|
|
616
605
|
e;
|
|
617
606
|
}
|
|
618
607
|
|
|
619
|
-
function
|
|
608
|
+
function L(e, t) {
|
|
620
609
|
var {
|
|
621
610
|
changeList: e,
|
|
622
611
|
fileLogLevel: i
|
|
@@ -630,17 +619,17 @@ function P(e, t) {
|
|
|
630
619
|
delta: a
|
|
631
620
|
} = e, i = e + ` "${i.fullPath ?? i}"`;
|
|
632
621
|
if ("delContent" === e) {
|
|
633
|
-
if (3
|
|
622
|
+
if (3 === t) return i + " " + JSON.stringify(r);
|
|
634
623
|
} else if ("insert" === e && 2 <= t) return {
|
|
635
624
|
oldValue: r,
|
|
636
625
|
newValue: e
|
|
637
|
-
} = a, a = `${
|
|
638
|
-
2
|
|
626
|
+
} = a, a = `${void 0 === r ? "" : "delta:"} ${JSON.stringify(r)} -> ` + JSON.stringify(e),
|
|
627
|
+
2 === t ? i + " " + a : i + ` ${a}. ` + (void 0 !== r ? "new: " + JSON.stringify(n) : "");
|
|
639
628
|
return i;
|
|
640
629
|
})(t, i)), e.push(t);
|
|
641
630
|
}
|
|
642
631
|
|
|
643
|
-
function
|
|
632
|
+
function q(e, t, i, r, n = void 0, a = void 0) {
|
|
644
633
|
var {
|
|
645
634
|
qyAclCmdGenerator: e,
|
|
646
635
|
qyCache: o,
|
|
@@ -651,7 +640,7 @@ function L(e, t, i, r, n = void 0, a = void 0) {
|
|
|
651
640
|
o && o.qyKVData.removeKey(r) && s.push(r, t);
|
|
652
641
|
}
|
|
653
642
|
|
|
654
|
-
function
|
|
643
|
+
function b(e, t, i, r = void 0, n = void 0) {
|
|
655
644
|
if (!t.underHiddenFolder) {
|
|
656
645
|
var a = e.qyCache.getIndexDir(t.parentDir);
|
|
657
646
|
if (a) {
|
|
@@ -667,19 +656,19 @@ function q(e, t, i, r = void 0, n = void 0) {
|
|
|
667
656
|
function N(t, e, i, r, n, a, o = void 0) {
|
|
668
657
|
e = _(e, i, n, a, o);
|
|
669
658
|
if (e) {
|
|
670
|
-
var s, l,
|
|
659
|
+
var s, l, h, {
|
|
671
660
|
toAddFileList: i,
|
|
672
661
|
toDelFileList: n
|
|
673
662
|
} = e;
|
|
674
663
|
for (s of i) t._setProp(s, r, 1);
|
|
675
664
|
for (l of n) l.created && t._setProp(l, r, null);
|
|
676
|
-
for (
|
|
677
|
-
var
|
|
678
|
-
if (
|
|
665
|
+
for (h of n) if (h.created) {
|
|
666
|
+
var c = h.fileContent;
|
|
667
|
+
if (void 0 === c || d(c)) {
|
|
679
668
|
t._action_delFile({
|
|
680
|
-
item:
|
|
669
|
+
item: h
|
|
681
670
|
});
|
|
682
|
-
let e =
|
|
671
|
+
let e = h.parentDir;
|
|
683
672
|
for (;e.created && !e.isHiddenFolder && e.isEmpty; ) t._action_delDir({
|
|
684
673
|
item: e
|
|
685
674
|
}), e = e.parentDir;
|
|
@@ -717,7 +706,7 @@ class I {
|
|
|
717
706
|
}
|
|
718
707
|
|
|
719
708
|
function E(e, t = void 0, i = [], r = {}) {
|
|
720
|
-
if (
|
|
709
|
+
if (h(e)) {
|
|
721
710
|
var n = t ? t(e) : e;
|
|
722
711
|
void 0 !== n && (r[JSON.stringify(i)] = n);
|
|
723
712
|
} else {
|
|
@@ -727,21 +716,21 @@ function E(e, t = void 0, i = [], r = {}) {
|
|
|
727
716
|
return r;
|
|
728
717
|
}
|
|
729
718
|
|
|
730
|
-
function
|
|
719
|
+
function S(e, t, i) {
|
|
731
720
|
return r(e) ? (t ? e : 1e3 * e) + i : l(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !a(e) || (t = e.getTime()) <= i ? void 0 : t;
|
|
732
721
|
}
|
|
733
722
|
|
|
734
|
-
function
|
|
735
|
-
var a = e.qyCache, r = (l(t) && (t = o(t)), "f"
|
|
736
|
-
return
|
|
723
|
+
function T(e, t, i, r, n) {
|
|
724
|
+
var a = e.qyCache, r = (l(t) && (t = o(t)), "f" === r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
725
|
+
return P(e, e._action_expireItem, {
|
|
737
726
|
item: r,
|
|
738
727
|
milliSecond: i
|
|
739
728
|
});
|
|
740
729
|
}
|
|
741
730
|
|
|
742
|
-
function
|
|
743
|
-
var a = e.qyCache, i = (l(t) && (t = o(t)), "f"
|
|
744
|
-
return
|
|
731
|
+
function j(e, t, i, r, n) {
|
|
732
|
+
var a = e.qyCache, i = (l(t) && (t = o(t)), "f" === i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
733
|
+
return P(e, e._action_removeItemExpire, {
|
|
745
734
|
item: i,
|
|
746
735
|
infoFileOnly: r
|
|
747
736
|
});
|
package/src/QyBinWriter.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./QyDefaultOptions.js";
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
logger as
|
|
25
|
+
logger as y
|
|
26
26
|
} from "./QyLogger.js";
|
|
27
27
|
|
|
28
28
|
class e extends t {
|
|
@@ -36,7 +36,7 @@ class e extends t {
|
|
|
36
36
|
}, a, i), this.filePath = e, h(this);
|
|
37
37
|
}
|
|
38
38
|
save(t, e = void 0, a = !1) {
|
|
39
|
-
|
|
39
|
+
void 0 === e && ([ e, t ] = [ t, 0 ]);
|
|
40
40
|
var i, r = this.lastOp;
|
|
41
41
|
return "_op_save" === r?.opFunName ? (i = r.args, i[0] = t, i[1].push(e),
|
|
42
42
|
a && s(r), r.promise) : (i = {
|
|
@@ -59,7 +59,7 @@ class e extends t {
|
|
|
59
59
|
}
|
|
60
60
|
getBinData(t, e = 0) {
|
|
61
61
|
var a = (t = t.flat()).length;
|
|
62
|
-
return 0
|
|
62
|
+
return 0 === a ? "" : 1 === a ? t[0] : Buffer.isBuffer(t[0]) ? Buffer.concat(t) : Buffer.concat(t.map(t => Buffer.from(t)));
|
|
63
63
|
}
|
|
64
64
|
async _op_start(t = void 0) {
|
|
65
65
|
return await i(this, t = t || this.filePath), this;
|
|
@@ -72,7 +72,7 @@ class e extends t {
|
|
|
72
72
|
if (t) try {
|
|
73
73
|
await t.close(), this.fileHandle = void 0;
|
|
74
74
|
} catch (t) {
|
|
75
|
-
|
|
75
|
+
y.error(`Close ${e} failed:`, t);
|
|
76
76
|
}
|
|
77
77
|
h(this);
|
|
78
78
|
}
|
|
@@ -96,8 +96,8 @@ class e extends t {
|
|
|
96
96
|
return n && 0 < e && t.emit("save", e), void (!t.maxFileSizeEmitted && l && m > l && (t.maxFileSizeEmitted = !0,
|
|
97
97
|
t.emit("maxFileSize", m)));
|
|
98
98
|
} catch (t) {
|
|
99
|
-
|
|
100
|
-
c = c ? Math.min(f, c * p) : 1,
|
|
99
|
+
y.error(`Saving ${d} failed:`, t, "Truncated back to " + r), await i.truncate(r),
|
|
100
|
+
c = c ? Math.min(f, c * p) : 1, y.log(`Retry in ${c} seconds`),
|
|
101
101
|
await _(c);
|
|
102
102
|
}
|
|
103
103
|
})(this, t, e);
|
|
@@ -108,9 +108,9 @@ class e extends t {
|
|
|
108
108
|
filePath: e
|
|
109
109
|
} = this;
|
|
110
110
|
if (t) try {
|
|
111
|
-
await t.truncate(0),
|
|
111
|
+
await t.truncate(0), y.info("Truncated " + e);
|
|
112
112
|
} catch (t) {
|
|
113
|
-
|
|
113
|
+
y.error(`Truncate ${e} failed:`, t);
|
|
114
114
|
}
|
|
115
115
|
h(this);
|
|
116
116
|
}
|
|
@@ -119,7 +119,7 @@ class e extends t {
|
|
|
119
119
|
fileHandle: e,
|
|
120
120
|
filePath: a
|
|
121
121
|
} = this;
|
|
122
|
-
e && a
|
|
122
|
+
e && a === t || (await i(this, t), y.info(`Switched from ${a} to ` + t));
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -137,15 +137,12 @@ async function i(t, e) {
|
|
|
137
137
|
} = i, o = r && await p(e) ? "r+" : s ? "w+" : "w";
|
|
138
138
|
t.fileHandle = await n(e, o), r && (t.totalSavedSize = await f(e));
|
|
139
139
|
} catch (t) {
|
|
140
|
-
|
|
140
|
+
y.error(`Open ${e} failed:`, t);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
function h(t) {
|
|
145
|
-
|
|
146
|
-
totalSavedSize: 0,
|
|
147
|
-
maxFileSizeEmitted: !1
|
|
148
|
-
});
|
|
145
|
+
t.totalSavedSize = 0, t.maxFileSizeEmitted = !1;
|
|
149
146
|
}
|
|
150
147
|
|
|
151
148
|
export {
|
package/src/QyBinaryHeap.js
CHANGED
|
@@ -8,7 +8,7 @@ class t {
|
|
|
8
8
|
return this.items.length;
|
|
9
9
|
}
|
|
10
10
|
get isEmpty() {
|
|
11
|
-
return 0
|
|
11
|
+
return 0 === this.items.length;
|
|
12
12
|
}
|
|
13
13
|
peek() {
|
|
14
14
|
return this.items[0];
|
|
@@ -30,7 +30,7 @@ class t {
|
|
|
30
30
|
let t = i;
|
|
31
31
|
0 < r(s[n], s[t]) && (t = n);
|
|
32
32
|
n = 1 + n;
|
|
33
|
-
if ((t = n < h && 0 < r(s[n], s[t]) ? n : t)
|
|
33
|
+
if ((t = n < h && 0 < r(s[n], s[t]) ? n : t) === i) break;
|
|
34
34
|
[ s[i], s[t] ] = [ s[t], s[i] ], i = t;
|
|
35
35
|
}
|
|
36
36
|
}
|