@poe-platform/safe-fs 0.1.801 → 0.1.803
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.
|
@@ -159,6 +159,7 @@ class FastDirectoryEntriesMap {
|
|
|
159
159
|
}
|
|
160
160
|
_rebuild(newCap) {
|
|
161
161
|
this._missKey = "";
|
|
162
|
+
this._missSlot = -1;
|
|
162
163
|
const newTableLen = newCap * 2;
|
|
163
164
|
const newMask = newTableLen - 1;
|
|
164
165
|
const newTable = newCap <= 16384 ? new Int16Array(newTableLen).fill(-1) : new Int32Array(newTableLen).fill(-1);
|
|
@@ -198,16 +199,17 @@ class FastDirectoryEntriesMap {
|
|
|
198
199
|
this._next = writeIdx;
|
|
199
200
|
}
|
|
200
201
|
set(k, v) {
|
|
201
|
-
|
|
202
|
+
const missSlot = k === this._missKey ? this._missSlot : -1;
|
|
203
|
+
this._missKey = "";
|
|
204
|
+
this._missSlot = -1;
|
|
205
|
+
if (missSlot >= 0 && (this._table[missSlot] === -1 || this._table[missSlot] === -2) && this._next < this._keys.length) {
|
|
202
206
|
const entryIdx = this._next++;
|
|
203
|
-
this._table[
|
|
207
|
+
this._table[missSlot] = entryIdx;
|
|
204
208
|
this._keys[entryIdx] = k;
|
|
205
209
|
this._vals[entryIdx] = v;
|
|
206
210
|
this.size++;
|
|
207
|
-
this._missKey = "";
|
|
208
211
|
return this;
|
|
209
212
|
}
|
|
210
|
-
this._missKey = "";
|
|
211
213
|
if (this._next >= this._keys.length) {
|
|
212
214
|
this._rebuild(this.size * 2 <= this._keys.length ? this._keys.length : this._keys.length * 2);
|
|
213
215
|
}
|
|
@@ -240,6 +242,7 @@ class FastDirectoryEntriesMap {
|
|
|
240
242
|
}
|
|
241
243
|
delete(k) {
|
|
242
244
|
this._missKey = "";
|
|
245
|
+
this._missSlot = -1;
|
|
243
246
|
if (this.size === 0)
|
|
244
247
|
return false;
|
|
245
248
|
let slot = this._hash(k);
|
|
@@ -268,6 +271,7 @@ class FastDirectoryEntriesMap {
|
|
|
268
271
|
}
|
|
269
272
|
clear() {
|
|
270
273
|
this._missKey = "";
|
|
274
|
+
this._missSlot = -1;
|
|
271
275
|
if (this._next > 0) {
|
|
272
276
|
this._table.fill(-1);
|
|
273
277
|
for (let i = 0; i < this._next; i++) {
|
|
@@ -893,6 +897,7 @@ export class MemoryFileSystem {
|
|
|
893
897
|
if (alloc.isReleased64()) {
|
|
894
898
|
alloc.detachLedger(DUMMY_POOL_LEDGER);
|
|
895
899
|
if (this.ledger.hasInfiniteRetained && this.ledger.hasInfiniteFileBytes && sharedAllocationPoolLen < SHARED_POOL_CAPACITY) {
|
|
900
|
+
alloc.data.fill(0);
|
|
896
901
|
sharedAllocationPool[sharedAllocationPoolLen++] = alloc;
|
|
897
902
|
}
|
|
898
903
|
else if (cache.allocations.length < 128) {
|
|
@@ -902,6 +907,7 @@ export class MemoryFileSystem {
|
|
|
902
907
|
else if (alloc.isReleased65536()) {
|
|
903
908
|
alloc.detachLedger(DUMMY_POOL_LEDGER);
|
|
904
909
|
if (this.ledger.hasInfiniteRetained && this.ledger.hasInfiniteFileBytes && sharedLargeAllocationPoolLen < SHARED_LARGE_POOL_CAPACITY) {
|
|
910
|
+
alloc.data.fill(0);
|
|
905
911
|
sharedLargeAllocationPool[sharedLargeAllocationPoolLen++] = alloc;
|
|
906
912
|
}
|
|
907
913
|
}
|
|
@@ -921,6 +927,7 @@ export class MemoryFileSystem {
|
|
|
921
927
|
cache.lastFastDirNode = undefined;
|
|
922
928
|
}
|
|
923
929
|
if (node.entries.size === 0) {
|
|
930
|
+
node.entries.clear();
|
|
924
931
|
if (sharedDirectoryNodePoolLen < SHARED_DIR_POOL_CAPACITY) {
|
|
925
932
|
sharedDirectoryNodePool[sharedDirectoryNodePoolLen++] = node;
|
|
926
933
|
}
|
|
@@ -937,6 +944,7 @@ export class MemoryFileSystem {
|
|
|
937
944
|
}
|
|
938
945
|
replaceData(node, allocation, length = allocation.data.byteLength) {
|
|
939
946
|
const previous = node.allocation;
|
|
947
|
+
node.sourceRef = undefined;
|
|
940
948
|
this.totalBytes += length - node.byteLength;
|
|
941
949
|
node.byteLength = length;
|
|
942
950
|
node.view = length === allocation.data.byteLength ? allocation.data : undefined;
|
|
@@ -945,12 +953,14 @@ export class MemoryFileSystem {
|
|
|
945
953
|
if (previous.isReleased64()) {
|
|
946
954
|
previous.detachLedger(DUMMY_POOL_LEDGER);
|
|
947
955
|
if (this.ledger.hasInfiniteRetained && this.ledger.hasInfiniteFileBytes && sharedAllocationPoolLen < SHARED_POOL_CAPACITY) {
|
|
956
|
+
previous.data.fill(0);
|
|
948
957
|
sharedAllocationPool[sharedAllocationPoolLen++] = previous;
|
|
949
958
|
}
|
|
950
959
|
}
|
|
951
960
|
else if (previous.isReleased65536()) {
|
|
952
961
|
previous.detachLedger(DUMMY_POOL_LEDGER);
|
|
953
962
|
if (this.ledger.hasInfiniteRetained && this.ledger.hasInfiniteFileBytes && sharedLargeAllocationPoolLen < SHARED_LARGE_POOL_CAPACITY) {
|
|
963
|
+
previous.data.fill(0);
|
|
954
964
|
sharedLargeAllocationPool[sharedLargeAllocationPoolLen++] = previous;
|
|
955
965
|
}
|
|
956
966
|
}
|
|
@@ -1581,6 +1591,7 @@ export class MemoryFileSystem {
|
|
|
1581
1591
|
node.byteLength = length;
|
|
1582
1592
|
node.view = length === allocation.data.byteLength ? allocation.data : undefined;
|
|
1583
1593
|
}
|
|
1594
|
+
node.sourceRef = undefined;
|
|
1584
1595
|
this.changed(node, now);
|
|
1585
1596
|
}
|
|
1586
1597
|
writeMemoryFileFast(path, data, append, mode) {
|
|
@@ -1832,6 +1843,7 @@ export class MemoryFileSystem {
|
|
|
1832
1843
|
const entries = parent.entries;
|
|
1833
1844
|
const existing = nameHash !== undefined ? entries.getForWriteWithHash(name, nameHash) : entries.getForWrite(name);
|
|
1834
1845
|
if (existing === undefined && entries._next < entries._keys.length) {
|
|
1846
|
+
this.ledger.reserve(name.length * 2, 2, "writeFile", name);
|
|
1835
1847
|
const now = fastWriteCachedNow;
|
|
1836
1848
|
const length = data.byteLength;
|
|
1837
1849
|
const node = sharedFileNodePool[--sharedFileNodePoolLen];
|
|
@@ -1858,7 +1870,6 @@ export class MemoryFileSystem {
|
|
|
1858
1870
|
entries._vals[entryIdx] = node;
|
|
1859
1871
|
entries.size++;
|
|
1860
1872
|
entries._missKey = "";
|
|
1861
|
-
this.ledger.reserve(name.length * 2, 2, "writeFile", name);
|
|
1862
1873
|
this.totalBytes += length;
|
|
1863
1874
|
this.mutationTick = (this.mutationTick + 1) | 0;
|
|
1864
1875
|
parent.revision = parent.revision < 1073741823 ? (parent.revision + 1) | 0 : Math.min(Number.MAX_SAFE_INTEGER + 1, parent.revision + 1);
|
|
@@ -3457,6 +3468,9 @@ export function getLastReadMemoryFileSourceRef(view) {
|
|
|
3457
3468
|
return ref;
|
|
3458
3469
|
}
|
|
3459
3470
|
export function tryReadMemoryFileViewSync(filesystem, path, maxBytes, signal, captureSourceRef = false) {
|
|
3471
|
+
// A capture belongs only to the most recent read, including failed/fallback reads.
|
|
3472
|
+
lastReadViewData = undefined;
|
|
3473
|
+
lastReadViewSourceRef = undefined;
|
|
3460
3474
|
const mem = filesystem;
|
|
3461
3475
|
if (mem._owner === undefined || !isStockMemoryMethods(mem, readFileFastMethodNames, false))
|
|
3462
3476
|
return undefined;
|
|
@@ -3472,6 +3486,8 @@ export function tryReadMemoryFileViewSync(filesystem, path, maxBytes, signal, ca
|
|
|
3472
3486
|
node.atimeMs = Date.now();
|
|
3473
3487
|
else if ((++fastWriteNowTick & 63) === 0)
|
|
3474
3488
|
node.atimeMs = fastWriteCachedNow = Date.now();
|
|
3489
|
+
else
|
|
3490
|
+
node.atimeMs = fastWriteCachedNow;
|
|
3475
3491
|
if (captureSourceRef && node.revision === 0) {
|
|
3476
3492
|
lastReadViewData = new WeakRef(data);
|
|
3477
3493
|
lastReadViewSourceRef = node.sourceRef === undefined ? undefined : new WeakRef(node.sourceRef);
|