sliftutils 0.46.0 → 0.47.0
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/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { PromiseObj, compareArray, sort, throttleFunction, timeInMinute } from "socket-function/src/misc";
|
|
2
2
|
import { IStorage, IStorageRaw } from "./IStorage";
|
|
3
3
|
import { Zip } from "../misc/zip";
|
|
4
|
-
import { runInSerial } from "socket-function/src/batching";
|
|
4
|
+
import { delay, runInSerial } from "socket-function/src/batching";
|
|
5
5
|
import { formatNumber, formatTime } from "socket-function/src/formatting/format";
|
|
6
6
|
import { setPending } from "./PendingManager";
|
|
7
7
|
import { isInBuild } from "../misc/environment";
|
|
8
|
+
import { isNode } from "typesafecss";
|
|
8
9
|
|
|
9
10
|
/*
|
|
10
11
|
// Spec:
|
|
@@ -466,8 +467,10 @@ export class TransactionStorage implements IStorage<Buffer> {
|
|
|
466
467
|
|
|
467
468
|
let newChunks = this.chunkBuffers(buffers);
|
|
468
469
|
|
|
470
|
+
let newFiles: string[] = [];
|
|
469
471
|
for (let chunk of newChunks) {
|
|
470
472
|
let file = this.getCurrentChunk();
|
|
473
|
+
newFiles.push(file);
|
|
471
474
|
this.currentChunk = undefined;
|
|
472
475
|
let content = chunk.buffer;
|
|
473
476
|
let { header, headerBuffer } = this.getHeader(
|
|
@@ -479,6 +482,21 @@ export class TransactionStorage implements IStorage<Buffer> {
|
|
|
479
482
|
}
|
|
480
483
|
let buffer = Buffer.concat([headerBuffer, content]);
|
|
481
484
|
await this.rawStorage.set(file, buffer);
|
|
485
|
+
let verified = await this.rawStorage.get(file);
|
|
486
|
+
if (!verified?.equals(buffer)) {
|
|
487
|
+
console.error(`Failed to verify transaction file ${file} in ${this.debugName}`);
|
|
488
|
+
throw new Error(`Failed to verify transaction file ${file} in ${this.debugName}`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
await delay(5000);
|
|
492
|
+
if (!isNode()) {
|
|
493
|
+
localStorage.setItem(`${this.debugName}-last-compress`, JSON.stringify({
|
|
494
|
+
time: Date.now(),
|
|
495
|
+
entryCount: this.entryCount,
|
|
496
|
+
cacheSize: this.cache.size,
|
|
497
|
+
newFiles,
|
|
498
|
+
existingDiskEntries,
|
|
499
|
+
}));
|
|
482
500
|
}
|
|
483
501
|
|
|
484
502
|
// This is the ONLY time we can delete old files, as we know for sure the new file has all of our data.
|