@fireproof/core 0.19.99 → 0.19.100
Sign up to get free protection for your applications and to get access to all the features.
- package/deno.json +3 -1
- package/index.cjs +74 -63
- package/index.cjs.map +1 -1
- package/index.global.js +552 -85
- package/index.global.js.map +1 -1
- package/index.js +75 -64
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/metafile-iife.json +1 -1
- package/package.json +4 -2
package/deno.json
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
"ipfs-unixfs-exporter": "npm:ipfs-unixfs-exporter@^13.6.1",
|
16
16
|
"memfs": "npm:memfs@^4.12.0",
|
17
17
|
"p-limit": "npm:p-limit@^6.1.0",
|
18
|
-
"react": "npm:react@^18.3.1"
|
18
|
+
"react": "npm:react@^18.3.1",
|
19
|
+
"p-map": "npm:p-map@^7.0.2",
|
20
|
+
"p-retry": "npm:p-retry@^6.2.0"
|
19
21
|
}
|
20
22
|
}
|
package/index.cjs
CHANGED
@@ -1149,7 +1149,6 @@ var UnixFSFileBuilder = class {
|
|
1149
1149
|
};
|
1150
1150
|
|
1151
1151
|
// src/blockstore/store.ts
|
1152
|
-
var import_p_limit2 = __toESM(require("p-limit"), 1);
|
1153
1152
|
var import_dag_json2 = require("@ipld/dag-json");
|
1154
1153
|
var import_cement10 = require("@adviser/cement");
|
1155
1154
|
|
@@ -2564,6 +2563,8 @@ async function encodeEventsWithParents(sthis, events, parents) {
|
|
2564
2563
|
}
|
2565
2564
|
|
2566
2565
|
// src/blockstore/store.ts
|
2566
|
+
var import_p_retry = __toESM(require("p-retry"), 1);
|
2567
|
+
var import_p_map = __toESM(require("p-map"), 1);
|
2567
2568
|
function guardVersion(url) {
|
2568
2569
|
if (!url.hasParam("version")) {
|
2569
2570
|
return import_cement10.Result.Err(`missing version: ${url.toString()}`);
|
@@ -2823,72 +2824,82 @@ var WALStoreImpl = class extends BaseStoreImpl {
|
|
2823
2824
|
}
|
2824
2825
|
async _doProcess() {
|
2825
2826
|
if (!this.loader.remoteCarStore) return;
|
2826
|
-
const
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2827
|
+
const operations = [...this.walState.operations];
|
2828
|
+
const noLoaderOps = [...this.walState.noLoaderOps];
|
2829
|
+
const fileOperations = [...this.walState.fileOperations];
|
2830
|
+
if (operations.length + noLoaderOps.length + fileOperations.length === 0) return;
|
2831
|
+
const concurrencyLimit = 3;
|
2832
|
+
const retryableUpload = (fn, description) => (0, import_p_retry.default)(fn, {
|
2833
|
+
retries: 5,
|
2834
|
+
onFailedAttempt: (error) => {
|
2835
|
+
this.logger.Warn().Msg(`Attempt ${error.attemptNumber} failed for ${description}. There are ${error.retriesLeft} retries left.`);
|
2836
|
+
}
|
2837
|
+
});
|
2838
|
+
try {
|
2839
|
+
await (0, import_p_map.default)(
|
2840
|
+
noLoaderOps,
|
2841
|
+
async (dbMeta) => {
|
2842
|
+
await retryableUpload(async () => {
|
2843
|
+
for (const cid of dbMeta.cars) {
|
2844
|
+
const car = await (await this.loader.carStore()).load(cid);
|
2845
|
+
if (!car) {
|
2846
|
+
if (carLogIncludesGroup(this.loader.carLog, dbMeta.cars)) {
|
2847
|
+
throw this.logger.Error().Ref("cid", cid).Msg("missing local car").AsError();
|
2848
|
+
}
|
2849
|
+
} else {
|
2850
|
+
await throwFalsy(this.loader.remoteCarStore).save(car);
|
2851
|
+
}
|
2842
2852
|
}
|
2843
2853
|
this.walState.noLoaderOps = this.walState.noLoaderOps.filter((op) => op !== dbMeta);
|
2844
|
-
}
|
2845
|
-
}
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2854
|
+
}, `noLoaderOp with dbMeta.cars=${dbMeta.cars.toString()}`);
|
2855
|
+
},
|
2856
|
+
{ concurrency: concurrencyLimit }
|
2857
|
+
);
|
2858
|
+
await (0, import_p_map.default)(
|
2859
|
+
operations,
|
2860
|
+
async (dbMeta) => {
|
2861
|
+
await retryableUpload(async () => {
|
2862
|
+
for (const cid of dbMeta.cars) {
|
2863
|
+
const car = await (await this.loader.carStore()).load(cid);
|
2864
|
+
if (!car) {
|
2865
|
+
if (carLogIncludesGroup(this.loader.carLog, dbMeta.cars)) {
|
2866
|
+
throw this.logger.Error().Ref("cid", cid).Msg(`missing local car`).AsError();
|
2867
|
+
}
|
2868
|
+
} else {
|
2869
|
+
await throwFalsy(this.loader.remoteCarStore).save(car);
|
2870
|
+
}
|
2857
2871
|
}
|
2858
|
-
|
2859
|
-
|
2860
|
-
}
|
2861
|
-
|
2862
|
-
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
const fileBlock = await (await
|
2868
|
-
|
2872
|
+
this.walState.operations = this.walState.operations.filter((op) => op !== dbMeta);
|
2873
|
+
}, `operation with dbMeta.cars=${dbMeta.cars.toString()}`);
|
2874
|
+
},
|
2875
|
+
{ concurrency: concurrencyLimit }
|
2876
|
+
);
|
2877
|
+
await (0, import_p_map.default)(
|
2878
|
+
fileOperations,
|
2879
|
+
async ({ cid: fileCid, public: publicFile }) => {
|
2880
|
+
await retryableUpload(async () => {
|
2881
|
+
const fileBlock = await (await this.loader.fileStore()).load(fileCid);
|
2882
|
+
if (!fileBlock) {
|
2883
|
+
throw this.logger.Error().Ref("cid", fileCid).Msg("missing file block").AsError();
|
2884
|
+
}
|
2885
|
+
await this.loader.remoteFileStore?.save(fileBlock, { public: publicFile });
|
2869
2886
|
this.walState.fileOperations = this.walState.fileOperations.filter((op) => op.cid !== fileCid);
|
2870
|
-
});
|
2871
|
-
|
2872
|
-
}
|
2873
|
-
|
2874
|
-
|
2875
|
-
const
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
}
|
2880
|
-
if (operations.length) {
|
2881
|
-
const lastOp = operations[operations.length - 1];
|
2882
|
-
await this.loader.remoteMetaStore?.save(lastOp).catch((e) => {
|
2883
|
-
this.walState.operations.push(lastOp);
|
2884
|
-
throw this.logger.Error().Any("error", e).Msg("error saving remote meta").AsError();
|
2885
|
-
});
|
2886
|
-
}
|
2887
|
-
} finally {
|
2888
|
-
await this.save(this.walState);
|
2887
|
+
}, `fileOperation with cid=${fileCid.toString()}`);
|
2888
|
+
},
|
2889
|
+
{ concurrency: concurrencyLimit }
|
2890
|
+
);
|
2891
|
+
if (operations.length) {
|
2892
|
+
const lastOp = operations[operations.length - 1];
|
2893
|
+
await retryableUpload(async () => {
|
2894
|
+
await this.loader.remoteMetaStore?.save(lastOp);
|
2895
|
+
}, `remoteMetaStore save with dbMeta.cars=${lastOp.cars.toString()}`);
|
2889
2896
|
}
|
2890
|
-
}
|
2891
|
-
|
2897
|
+
} catch (error) {
|
2898
|
+
this.logger.Error().Any("error", error).Msg("Processing failed");
|
2899
|
+
return;
|
2900
|
+
} finally {
|
2901
|
+
await this.save(this.walState);
|
2902
|
+
}
|
2892
2903
|
}
|
2893
2904
|
async load() {
|
2894
2905
|
this.logger.Debug().Msg("loading");
|
@@ -4324,6 +4335,6 @@ init_utils();
|
|
4324
4335
|
|
4325
4336
|
// src/version.ts
|
4326
4337
|
var PACKAGE_VERSION = Object.keys({
|
4327
|
-
"0.19.
|
4338
|
+
"0.19.100": "xxxx"
|
4328
4339
|
})[0];
|
4329
4340
|
//# sourceMappingURL=index.cjs.map
|