cryptpad-server 0.0.3 → 0.0.5
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/build/core.js +19 -5
- package/build/core.worker.js +7 -0
- package/build/front.js +27 -10
- package/build/http.js +18 -4
- package/build/http.worker.js +17 -3
- package/build/storage.cluster.js +13 -3
- package/build/storage.js +25 -4
- package/build/storage.worker.js +91 -9
- package/build/websocket.js +35556 -0
- package/build/ws.worker.js +46222 -0
- package/index.js +35 -38
- package/package.json +4 -2
- package/readme.md +1 -5
package/build/core.js
CHANGED
|
@@ -1354,6 +1354,9 @@ function requireWsConnector() {
|
|
|
1354
1354
|
cb(void 0, ctx.self);
|
|
1355
1355
|
};
|
|
1356
1356
|
const port = config.wsPort || config.port;
|
|
1357
|
+
httpServer.on("error", e => {
|
|
1358
|
+
cb(e);
|
|
1359
|
+
});
|
|
1357
1360
|
httpServer.listen(port, config.host, onServerReady);
|
|
1358
1361
|
},
|
|
1359
1362
|
initClient: (ctx, config, id, onConnected, cb) => {
|
|
@@ -2895,8 +2898,9 @@ function requireSchedule() {
|
|
|
2895
2898
|
};
|
|
2896
2899
|
var runOnceUnblocked = function(local, task) {
|
|
2897
2900
|
var uid = unusedUid(local.blocked);
|
|
2898
|
-
local.blocked[uid] = function() {
|
|
2899
|
-
|
|
2901
|
+
local.blocked[uid] = function(next) {
|
|
2902
|
+
delete local.blocked[uid];
|
|
2903
|
+
task(next);
|
|
2900
2904
|
};
|
|
2901
2905
|
};
|
|
2902
2906
|
var Unordered = function(id, task) {
|
|
@@ -3153,6 +3157,14 @@ function requireFile() {
|
|
|
3153
3157
|
writeLinkedFile(env, path, content, cb);
|
|
3154
3158
|
});
|
|
3155
3159
|
};
|
|
3160
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
3161
|
+
const path = mkLinkedPath(env, channelId);
|
|
3162
|
+
try {
|
|
3163
|
+
return Fs.existsSync(path);
|
|
3164
|
+
} catch (e) {
|
|
3165
|
+
return false;
|
|
3166
|
+
}
|
|
3167
|
+
};
|
|
3156
3168
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
3157
3169
|
const path = mkLinkedPath(env, channelId);
|
|
3158
3170
|
readLinkedFile(env, path, cb);
|
|
@@ -4225,6 +4237,7 @@ function requireFile() {
|
|
|
4225
4237
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
4226
4238
|
});
|
|
4227
4239
|
},
|
|
4240
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
4228
4241
|
getLinkedDocuments: (channelId, cb) => {
|
|
4229
4242
|
if (!isValidChannelId(channelId)) {
|
|
4230
4243
|
return cb(new Error("EINVAL"));
|
|
@@ -7682,7 +7695,7 @@ function requireHttpCommands() {
|
|
|
7682
7695
|
return httpCommands;
|
|
7683
7696
|
}
|
|
7684
7697
|
|
|
7685
|
-
var version = "0.0.
|
|
7698
|
+
var version = "0.0.5";
|
|
7686
7699
|
|
|
7687
7700
|
var require$$2 = {
|
|
7688
7701
|
version
|
|
@@ -9077,7 +9090,6 @@ function requireCore() {
|
|
|
9077
9090
|
};
|
|
9078
9091
|
const {challengePath} = Core.getPaths(mainConfig);
|
|
9079
9092
|
Env.challengePath = challengePath;
|
|
9080
|
-
Env.workers = WorkerModule(workerConfig);
|
|
9081
9093
|
let queriesToStorage = [];
|
|
9082
9094
|
let queriesToFront = [];
|
|
9083
9095
|
let eventsToStorage = [];
|
|
@@ -9122,11 +9134,13 @@ function requireCore() {
|
|
|
9122
9134
|
Env.Log.error("INTERFACE_INIT_ERROR", err);
|
|
9123
9135
|
return;
|
|
9124
9136
|
}
|
|
9137
|
+
Env.workers = WorkerModule(workerConfig);
|
|
9125
9138
|
if (process.send !== undefined) {
|
|
9126
9139
|
process.send({
|
|
9127
9140
|
type: "core",
|
|
9128
9141
|
index,
|
|
9129
|
-
msg: "READY"
|
|
9142
|
+
msg: "READY",
|
|
9143
|
+
pid: process.pid
|
|
9130
9144
|
});
|
|
9131
9145
|
}
|
|
9132
9146
|
checkCacheInterval();
|
package/build/core.worker.js
CHANGED
|
@@ -970,6 +970,10 @@ function requireWorker() {
|
|
|
970
970
|
txid: obj.txid,
|
|
971
971
|
pid: obj.pid,
|
|
972
972
|
value
|
|
973
|
+
}, e => {
|
|
974
|
+
if (e) {
|
|
975
|
+
console.error("E_RESPONSE", Util.serializeError(e));
|
|
976
|
+
}
|
|
973
977
|
});
|
|
974
978
|
};
|
|
975
979
|
if (!ready) {
|
|
@@ -986,6 +990,9 @@ function requireWorker() {
|
|
|
986
990
|
}
|
|
987
991
|
command(data, cb);
|
|
988
992
|
});
|
|
993
|
+
process.on("disconnect", () => {
|
|
994
|
+
process.exit(0);
|
|
995
|
+
});
|
|
989
996
|
process.on("uncaughtException", function(err) {
|
|
990
997
|
console.error("[%s] UNCAUGHT EXCEPTION IN DB WORKER", new Date);
|
|
991
998
|
console.error(err);
|
package/build/front.js
CHANGED
|
@@ -1358,6 +1358,9 @@ function requireWsConnector() {
|
|
|
1358
1358
|
cb(void 0, ctx.self);
|
|
1359
1359
|
};
|
|
1360
1360
|
const port = config.wsPort || config.port;
|
|
1361
|
+
httpServer.on("error", e => {
|
|
1362
|
+
cb(e);
|
|
1363
|
+
});
|
|
1361
1364
|
httpServer.listen(port, config.host, onServerReady);
|
|
1362
1365
|
},
|
|
1363
1366
|
initClient: (ctx, config, id, onConnected, cb) => {
|
|
@@ -2514,8 +2517,9 @@ function requireSchedule() {
|
|
|
2514
2517
|
};
|
|
2515
2518
|
var runOnceUnblocked = function(local, task) {
|
|
2516
2519
|
var uid = unusedUid(local.blocked);
|
|
2517
|
-
local.blocked[uid] = function() {
|
|
2518
|
-
|
|
2520
|
+
local.blocked[uid] = function(next) {
|
|
2521
|
+
delete local.blocked[uid];
|
|
2522
|
+
task(next);
|
|
2519
2523
|
};
|
|
2520
2524
|
};
|
|
2521
2525
|
var Unordered = function(id, task) {
|
|
@@ -2772,6 +2776,14 @@ function requireFile() {
|
|
|
2772
2776
|
writeLinkedFile(env, path, content, cb);
|
|
2773
2777
|
});
|
|
2774
2778
|
};
|
|
2779
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
2780
|
+
const path = mkLinkedPath(env, channelId);
|
|
2781
|
+
try {
|
|
2782
|
+
return Fs.existsSync(path);
|
|
2783
|
+
} catch (e) {
|
|
2784
|
+
return false;
|
|
2785
|
+
}
|
|
2786
|
+
};
|
|
2775
2787
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
2776
2788
|
const path = mkLinkedPath(env, channelId);
|
|
2777
2789
|
readLinkedFile(env, path, cb);
|
|
@@ -3844,6 +3856,7 @@ function requireFile() {
|
|
|
3844
3856
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
3845
3857
|
});
|
|
3846
3858
|
},
|
|
3859
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
3847
3860
|
getLinkedDocuments: (channelId, cb) => {
|
|
3848
3861
|
if (!isValidChannelId(channelId)) {
|
|
3849
3862
|
return cb(new Error("EINVAL"));
|
|
@@ -4049,7 +4062,7 @@ function requireLogger() {
|
|
|
4049
4062
|
return logger;
|
|
4050
4063
|
}
|
|
4051
4064
|
|
|
4052
|
-
var version = "0.0.
|
|
4065
|
+
var version = "0.0.5";
|
|
4053
4066
|
|
|
4054
4067
|
var require$$2 = {
|
|
4055
4068
|
version
|
|
@@ -5052,13 +5065,16 @@ function requireNetwork() {
|
|
|
5052
5065
|
};
|
|
5053
5066
|
};
|
|
5054
5067
|
const serveConfig = makeRouteCache(function() {
|
|
5055
|
-
const ssoList = Env.sso &&
|
|
5068
|
+
const ssoList = Env.sso && Array.isArray(Env.sso.list) && Env.sso.list.map(function(obj) {
|
|
5056
5069
|
return obj.name;
|
|
5057
5070
|
}) || [];
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5071
|
+
let forceSso = Env?.sso?.enforced ?? true;
|
|
5072
|
+
let allowPw = Env?.sso?.cpPassword ?? true;
|
|
5073
|
+
let forcePw = Env?.sso?.forceCpPassword ?? true;
|
|
5074
|
+
const ssoCfg = Env?.sso?.enabled ? {
|
|
5075
|
+
enabled: Env?.sso?.enabled,
|
|
5076
|
+
force: forceSso ? 1 : 0,
|
|
5077
|
+
password: allowPw && (forcePw ? 2 : 1) || 0,
|
|
5062
5078
|
list: ssoList
|
|
5063
5079
|
} : false;
|
|
5064
5080
|
return [ "define(function(){", "return " + JSON.stringify({
|
|
@@ -5135,7 +5151,7 @@ function requireNetwork() {
|
|
|
5135
5151
|
});
|
|
5136
5152
|
app.use(Express.json());
|
|
5137
5153
|
app.post("/api/auth", (req, res) => {
|
|
5138
|
-
const body = Util.clone(req.body);
|
|
5154
|
+
const body = Util.clone(req.body) || {};
|
|
5139
5155
|
const cookies = req.cookies;
|
|
5140
5156
|
body._cookies = cookies;
|
|
5141
5157
|
events.httpCommand.fire(body, (err, response) => {
|
|
@@ -5795,7 +5811,8 @@ function requireFront() {
|
|
|
5795
5811
|
process.send({
|
|
5796
5812
|
type: "front",
|
|
5797
5813
|
index,
|
|
5798
|
-
msg: "READY"
|
|
5814
|
+
msg: "READY",
|
|
5815
|
+
pid: process.pid
|
|
5799
5816
|
});
|
|
5800
5817
|
} else {
|
|
5801
5818
|
Env.Log.info("SINGLE_FRONT_STARTED", Env.myId);
|
package/build/http.js
CHANGED
|
@@ -1942,8 +1942,9 @@ function requireSchedule() {
|
|
|
1942
1942
|
};
|
|
1943
1943
|
var runOnceUnblocked = function(local, task) {
|
|
1944
1944
|
var uid = unusedUid(local.blocked);
|
|
1945
|
-
local.blocked[uid] = function() {
|
|
1946
|
-
|
|
1945
|
+
local.blocked[uid] = function(next) {
|
|
1946
|
+
delete local.blocked[uid];
|
|
1947
|
+
task(next);
|
|
1947
1948
|
};
|
|
1948
1949
|
};
|
|
1949
1950
|
var Unordered = function(id, task) {
|
|
@@ -2200,6 +2201,14 @@ function requireFile() {
|
|
|
2200
2201
|
writeLinkedFile(env, path, content, cb);
|
|
2201
2202
|
});
|
|
2202
2203
|
};
|
|
2204
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
2205
|
+
const path = mkLinkedPath(env, channelId);
|
|
2206
|
+
try {
|
|
2207
|
+
return Fs.existsSync(path);
|
|
2208
|
+
} catch (e) {
|
|
2209
|
+
return false;
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2203
2212
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
2204
2213
|
const path = mkLinkedPath(env, channelId);
|
|
2205
2214
|
readLinkedFile(env, path, cb);
|
|
@@ -3272,6 +3281,7 @@ function requireFile() {
|
|
|
3272
3281
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
3273
3282
|
});
|
|
3274
3283
|
},
|
|
3284
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
3275
3285
|
getLinkedDocuments: (channelId, cb) => {
|
|
3276
3286
|
if (!isValidChannelId(channelId)) {
|
|
3277
3287
|
return cb(new Error("EINVAL"));
|
|
@@ -3477,7 +3487,7 @@ function requireLogger() {
|
|
|
3477
3487
|
return logger;
|
|
3478
3488
|
}
|
|
3479
3489
|
|
|
3480
|
-
var version = "0.0.
|
|
3490
|
+
var version = "0.0.5";
|
|
3481
3491
|
|
|
3482
3492
|
var require$$2 = {
|
|
3483
3493
|
version
|
|
@@ -5172,6 +5182,9 @@ function requireWsConnector() {
|
|
|
5172
5182
|
cb(void 0, ctx.self);
|
|
5173
5183
|
};
|
|
5174
5184
|
const port = config.wsPort || config.port;
|
|
5185
|
+
httpServer.on("error", e => {
|
|
5186
|
+
cb(e);
|
|
5187
|
+
});
|
|
5175
5188
|
httpServer.listen(port, config.host, onServerReady);
|
|
5176
5189
|
},
|
|
5177
5190
|
initClient: (ctx, config, id, onConnected, cb) => {
|
|
@@ -5313,7 +5326,8 @@ function requireHttpServer() {
|
|
|
5313
5326
|
type: "http",
|
|
5314
5327
|
index: 0,
|
|
5315
5328
|
dev: Env.DEV_MODE,
|
|
5316
|
-
msg: "READY"
|
|
5329
|
+
msg: "READY",
|
|
5330
|
+
pid: process.pid
|
|
5317
5331
|
});
|
|
5318
5332
|
});
|
|
5319
5333
|
};
|
package/build/http.worker.js
CHANGED
|
@@ -1952,8 +1952,9 @@ function requireSchedule() {
|
|
|
1952
1952
|
};
|
|
1953
1953
|
var runOnceUnblocked = function(local, task) {
|
|
1954
1954
|
var uid = unusedUid(local.blocked);
|
|
1955
|
-
local.blocked[uid] = function() {
|
|
1956
|
-
|
|
1955
|
+
local.blocked[uid] = function(next) {
|
|
1956
|
+
delete local.blocked[uid];
|
|
1957
|
+
task(next);
|
|
1957
1958
|
};
|
|
1958
1959
|
};
|
|
1959
1960
|
var Unordered = function(id, task) {
|
|
@@ -2210,6 +2211,14 @@ function requireFile() {
|
|
|
2210
2211
|
writeLinkedFile(env, path, content, cb);
|
|
2211
2212
|
});
|
|
2212
2213
|
};
|
|
2214
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
2215
|
+
const path = mkLinkedPath(env, channelId);
|
|
2216
|
+
try {
|
|
2217
|
+
return Fs.existsSync(path);
|
|
2218
|
+
} catch (e) {
|
|
2219
|
+
return false;
|
|
2220
|
+
}
|
|
2221
|
+
};
|
|
2213
2222
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
2214
2223
|
const path = mkLinkedPath(env, channelId);
|
|
2215
2224
|
readLinkedFile(env, path, cb);
|
|
@@ -3282,6 +3291,7 @@ function requireFile() {
|
|
|
3282
3291
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
3283
3292
|
});
|
|
3284
3293
|
},
|
|
3294
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
3285
3295
|
getLinkedDocuments: (channelId, cb) => {
|
|
3286
3296
|
if (!isValidChannelId(channelId)) {
|
|
3287
3297
|
return cb(new Error("EINVAL"));
|
|
@@ -3529,7 +3539,7 @@ function requireDefaults() {
|
|
|
3529
3539
|
return defaults.exports;
|
|
3530
3540
|
}
|
|
3531
3541
|
|
|
3532
|
-
var version = "0.0.
|
|
3542
|
+
var version = "0.0.5";
|
|
3533
3543
|
|
|
3534
3544
|
var require$$2 = {
|
|
3535
3545
|
version
|
|
@@ -4611,6 +4621,10 @@ function requireWorker() {
|
|
|
4611
4621
|
txid: obj.txid,
|
|
4612
4622
|
pid: obj.pid,
|
|
4613
4623
|
value
|
|
4624
|
+
}, e => {
|
|
4625
|
+
if (e) {
|
|
4626
|
+
console.error("E_RESPONSE", Util.serializeError(e));
|
|
4627
|
+
}
|
|
4614
4628
|
});
|
|
4615
4629
|
};
|
|
4616
4630
|
if (!ready) {
|
package/build/storage.cluster.js
CHANGED
|
@@ -2879,7 +2879,7 @@ function requireMfa() {
|
|
|
2879
2879
|
return mfa.exports;
|
|
2880
2880
|
}
|
|
2881
2881
|
|
|
2882
|
-
var version = "0.0.
|
|
2882
|
+
var version = "0.0.5";
|
|
2883
2883
|
|
|
2884
2884
|
var require$$2 = {
|
|
2885
2885
|
version
|
|
@@ -2991,8 +2991,9 @@ function requireSchedule() {
|
|
|
2991
2991
|
};
|
|
2992
2992
|
var runOnceUnblocked = function(local, task) {
|
|
2993
2993
|
var uid = unusedUid(local.blocked);
|
|
2994
|
-
local.blocked[uid] = function() {
|
|
2995
|
-
|
|
2994
|
+
local.blocked[uid] = function(next) {
|
|
2995
|
+
delete local.blocked[uid];
|
|
2996
|
+
task(next);
|
|
2996
2997
|
};
|
|
2997
2998
|
};
|
|
2998
2999
|
var Unordered = function(id, task) {
|
|
@@ -4473,6 +4474,14 @@ function requireFile() {
|
|
|
4473
4474
|
writeLinkedFile(env, path, content, cb);
|
|
4474
4475
|
});
|
|
4475
4476
|
};
|
|
4477
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
4478
|
+
const path = mkLinkedPath(env, channelId);
|
|
4479
|
+
try {
|
|
4480
|
+
return Fs.existsSync(path);
|
|
4481
|
+
} catch (e) {
|
|
4482
|
+
return false;
|
|
4483
|
+
}
|
|
4484
|
+
};
|
|
4476
4485
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
4477
4486
|
const path = mkLinkedPath(env, channelId);
|
|
4478
4487
|
readLinkedFile(env, path, cb);
|
|
@@ -5545,6 +5554,7 @@ function requireFile() {
|
|
|
5545
5554
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
5546
5555
|
});
|
|
5547
5556
|
},
|
|
5557
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
5548
5558
|
getLinkedDocuments: (channelId, cb) => {
|
|
5549
5559
|
if (!isValidChannelId(channelId)) {
|
|
5550
5560
|
return cb(new Error("EINVAL"));
|
package/build/storage.js
CHANGED
|
@@ -1944,8 +1944,9 @@ function requireSchedule() {
|
|
|
1944
1944
|
};
|
|
1945
1945
|
var runOnceUnblocked = function(local, task) {
|
|
1946
1946
|
var uid = unusedUid(local.blocked);
|
|
1947
|
-
local.blocked[uid] = function() {
|
|
1948
|
-
|
|
1947
|
+
local.blocked[uid] = function(next) {
|
|
1948
|
+
delete local.blocked[uid];
|
|
1949
|
+
task(next);
|
|
1949
1950
|
};
|
|
1950
1951
|
};
|
|
1951
1952
|
var Unordered = function(id, task) {
|
|
@@ -2202,6 +2203,14 @@ function requireFile() {
|
|
|
2202
2203
|
writeLinkedFile(env, path, content, cb);
|
|
2203
2204
|
});
|
|
2204
2205
|
};
|
|
2206
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
2207
|
+
const path = mkLinkedPath(env, channelId);
|
|
2208
|
+
try {
|
|
2209
|
+
return Fs.existsSync(path);
|
|
2210
|
+
} catch (e) {
|
|
2211
|
+
return false;
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2205
2214
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
2206
2215
|
const path = mkLinkedPath(env, channelId);
|
|
2207
2216
|
readLinkedFile(env, path, cb);
|
|
@@ -3274,6 +3283,7 @@ function requireFile() {
|
|
|
3274
3283
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
3275
3284
|
});
|
|
3276
3285
|
},
|
|
3286
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
3277
3287
|
getLinkedDocuments: (channelId, cb) => {
|
|
3278
3288
|
if (!isValidChannelId(channelId)) {
|
|
3279
3289
|
return cb(new Error("EINVAL"));
|
|
@@ -5025,10 +5035,17 @@ function requireChannelManager() {
|
|
|
5025
5035
|
}
|
|
5026
5036
|
}));
|
|
5027
5037
|
}).nThen(function(w) {
|
|
5038
|
+
if (!store.hasLinkedDocuments(channel)) {
|
|
5039
|
+
return;
|
|
5040
|
+
}
|
|
5028
5041
|
Linked.trimHistory(Env, {
|
|
5029
5042
|
channel
|
|
5030
5043
|
}, w());
|
|
5031
5044
|
}).nThen(function() {
|
|
5045
|
+
Env.Log.info("HK_TRIM_HISTORY_START", {
|
|
5046
|
+
unsafeKey,
|
|
5047
|
+
channel
|
|
5048
|
+
});
|
|
5032
5049
|
store.trimChannel(channel, hash, err => {
|
|
5033
5050
|
Env.Log.info("HK_TRIM_HISTORY", {
|
|
5034
5051
|
unsafeKey,
|
|
@@ -6695,7 +6712,7 @@ function requireMfaManager() {
|
|
|
6695
6712
|
return mfaManager;
|
|
6696
6713
|
}
|
|
6697
6714
|
|
|
6698
|
-
var version = "0.0.
|
|
6715
|
+
var version = "0.0.5";
|
|
6699
6716
|
|
|
6700
6717
|
var require$$2 = {
|
|
6701
6718
|
version
|
|
@@ -7924,6 +7941,9 @@ function requireWsConnector() {
|
|
|
7924
7941
|
cb(void 0, ctx.self);
|
|
7925
7942
|
};
|
|
7926
7943
|
const port = config.wsPort || config.port;
|
|
7944
|
+
httpServer.on("error", e => {
|
|
7945
|
+
cb(e);
|
|
7946
|
+
});
|
|
7927
7947
|
httpServer.listen(port, config.host, onServerReady);
|
|
7928
7948
|
},
|
|
7929
7949
|
initClient: (ctx, config, id, onConnected, cb) => {
|
|
@@ -12113,7 +12133,8 @@ function requireStorage() {
|
|
|
12113
12133
|
process.send({
|
|
12114
12134
|
type: "storage",
|
|
12115
12135
|
index,
|
|
12116
|
-
msg: "READY"
|
|
12136
|
+
msg: "READY",
|
|
12137
|
+
pid: process.pid
|
|
12117
12138
|
});
|
|
12118
12139
|
} else {
|
|
12119
12140
|
console.log(myId, "started");
|
package/build/storage.worker.js
CHANGED
|
@@ -1946,8 +1946,9 @@ function requireSchedule() {
|
|
|
1946
1946
|
};
|
|
1947
1947
|
var runOnceUnblocked = function(local, task) {
|
|
1948
1948
|
var uid = unusedUid(local.blocked);
|
|
1949
|
-
local.blocked[uid] = function() {
|
|
1950
|
-
|
|
1949
|
+
local.blocked[uid] = function(next) {
|
|
1950
|
+
delete local.blocked[uid];
|
|
1951
|
+
task(next);
|
|
1951
1952
|
};
|
|
1952
1953
|
};
|
|
1953
1954
|
var Unordered = function(id, task) {
|
|
@@ -2204,6 +2205,14 @@ function requireFile() {
|
|
|
2204
2205
|
writeLinkedFile(env, path, content, cb);
|
|
2205
2206
|
});
|
|
2206
2207
|
};
|
|
2208
|
+
const hasLinkedDocuments = (env, channelId) => {
|
|
2209
|
+
const path = mkLinkedPath(env, channelId);
|
|
2210
|
+
try {
|
|
2211
|
+
return Fs.existsSync(path);
|
|
2212
|
+
} catch (e) {
|
|
2213
|
+
return false;
|
|
2214
|
+
}
|
|
2215
|
+
};
|
|
2207
2216
|
const getLinkedDocuments = (env, channelId, cb) => {
|
|
2208
2217
|
const path = mkLinkedPath(env, channelId);
|
|
2209
2218
|
readLinkedFile(env, path, cb);
|
|
@@ -3276,6 +3285,7 @@ function requireFile() {
|
|
|
3276
3285
|
writeMetadata(env, channelName, data, Util.both(cb, next));
|
|
3277
3286
|
});
|
|
3278
3287
|
},
|
|
3288
|
+
hasLinkedDocuments: channelId => hasLinkedDocuments(env, channelId),
|
|
3279
3289
|
getLinkedDocuments: (channelId, cb) => {
|
|
3280
3290
|
if (!isValidChannelId(channelId)) {
|
|
3281
3291
|
return cb(new Error("EINVAL"));
|
|
@@ -4731,7 +4741,7 @@ function requireTasks() {
|
|
|
4731
4741
|
return tasks.exports;
|
|
4732
4742
|
}
|
|
4733
4743
|
|
|
4734
|
-
var version = "0.0.
|
|
4744
|
+
var version = "0.0.5";
|
|
4735
4745
|
|
|
4736
4746
|
var require$$2 = {
|
|
4737
4747
|
version
|
|
@@ -5589,10 +5599,11 @@ function requirePinManager() {
|
|
|
5589
5599
|
hasRequiredPinManager = 1;
|
|
5590
5600
|
(function(module) {
|
|
5591
5601
|
const Pins = module.exports;
|
|
5592
|
-
__require$2();
|
|
5593
|
-
__require$1();
|
|
5594
|
-
requireCommonUtil$1();
|
|
5595
|
-
|
|
5602
|
+
const Fs = __require$2();
|
|
5603
|
+
const Path = __require$1();
|
|
5604
|
+
const Util = requireCommonUtil$1();
|
|
5605
|
+
const Semaphore = require$$4;
|
|
5606
|
+
const nThen = require$$3;
|
|
5596
5607
|
const createLineHandler = Pins.createLineHandler = (ref, errorHandler) => {
|
|
5597
5608
|
let fileName;
|
|
5598
5609
|
if (typeof errorHandler === "string") {
|
|
@@ -5712,8 +5723,72 @@ function requirePinManager() {
|
|
|
5712
5723
|
const ref = processPinFile(pinFile, fileName);
|
|
5713
5724
|
return Object.keys(ref.pins);
|
|
5714
5725
|
};
|
|
5715
|
-
Pins.load = (cb, config) => {
|
|
5716
|
-
|
|
5726
|
+
Pins.load = (Env, cb, config) => {
|
|
5727
|
+
const sema = Semaphore.create(config.workers || 5);
|
|
5728
|
+
let dirList;
|
|
5729
|
+
const fileList = [];
|
|
5730
|
+
const pinned = {};
|
|
5731
|
+
var done = Util.once(cb);
|
|
5732
|
+
var handler = config.handler;
|
|
5733
|
+
let store = Env.pinStore;
|
|
5734
|
+
let pinPath = Env.paths.pin;
|
|
5735
|
+
nThen(waitFor => {
|
|
5736
|
+
Fs.readdir(pinPath, waitFor((err, list) => {
|
|
5737
|
+
if (err) {
|
|
5738
|
+
if (err.code === "ENOENT") {
|
|
5739
|
+
dirList = [];
|
|
5740
|
+
return;
|
|
5741
|
+
}
|
|
5742
|
+
waitFor.abort();
|
|
5743
|
+
return void done(err);
|
|
5744
|
+
}
|
|
5745
|
+
dirList = list;
|
|
5746
|
+
}));
|
|
5747
|
+
}).nThen(waitFor => {
|
|
5748
|
+
dirList.forEach(f => {
|
|
5749
|
+
sema.take(returnAfter => {
|
|
5750
|
+
Fs.readdir(Path.join(pinPath, f), waitFor(returnAfter((err, list2) => {
|
|
5751
|
+
if (err) {
|
|
5752
|
+
waitFor.abort();
|
|
5753
|
+
return void done(err);
|
|
5754
|
+
}
|
|
5755
|
+
list2.forEach(ff => {
|
|
5756
|
+
if (config && config.exclude && config.exclude.indexOf(ff) > -1) {
|
|
5757
|
+
return;
|
|
5758
|
+
}
|
|
5759
|
+
fileList.push(ff.replace(/(\.ndjson)$/, ""));
|
|
5760
|
+
});
|
|
5761
|
+
})));
|
|
5762
|
+
});
|
|
5763
|
+
});
|
|
5764
|
+
}).nThen(waitFor => {
|
|
5765
|
+
fileList.forEach(id => {
|
|
5766
|
+
sema.take(returnAfter => {
|
|
5767
|
+
var next = waitFor(returnAfter());
|
|
5768
|
+
var ref = {};
|
|
5769
|
+
var h = createLineHandler(ref, id);
|
|
5770
|
+
store.readMessagesBin(id, 0, (msgObj, next) => {
|
|
5771
|
+
h(msgObj.buff.toString("utf8"));
|
|
5772
|
+
next();
|
|
5773
|
+
}, err => {
|
|
5774
|
+
if (err) {
|
|
5775
|
+
waitFor.abort();
|
|
5776
|
+
return void done(err);
|
|
5777
|
+
}
|
|
5778
|
+
if (handler) {
|
|
5779
|
+
return void handler(ref, id, next);
|
|
5780
|
+
}
|
|
5781
|
+
const hashes = Object.keys(ref.pins);
|
|
5782
|
+
hashes.forEach(x => {
|
|
5783
|
+
(pinned[x] = pinned[x] || {})[id] = 1;
|
|
5784
|
+
});
|
|
5785
|
+
next();
|
|
5786
|
+
});
|
|
5787
|
+
});
|
|
5788
|
+
});
|
|
5789
|
+
}).nThen(() => {
|
|
5790
|
+
done(void 0, pinned);
|
|
5791
|
+
});
|
|
5717
5792
|
};
|
|
5718
5793
|
})(pinManager);
|
|
5719
5794
|
return pinManager.exports;
|
|
@@ -6519,6 +6594,10 @@ function requireWorker() {
|
|
|
6519
6594
|
txid: obj.txid,
|
|
6520
6595
|
pid: obj.pid,
|
|
6521
6596
|
value
|
|
6597
|
+
}, e => {
|
|
6598
|
+
if (e) {
|
|
6599
|
+
console.error("E_RESPONSE", Util.serializeError(e));
|
|
6600
|
+
}
|
|
6522
6601
|
});
|
|
6523
6602
|
};
|
|
6524
6603
|
if (!ready) {
|
|
@@ -6535,6 +6614,9 @@ function requireWorker() {
|
|
|
6535
6614
|
}
|
|
6536
6615
|
command(data, cb);
|
|
6537
6616
|
});
|
|
6617
|
+
process.on("disconnect", () => {
|
|
6618
|
+
process.exit(0);
|
|
6619
|
+
});
|
|
6538
6620
|
process.on("uncaughtException", function(err) {
|
|
6539
6621
|
console.error("[%s] UNCAUGHT EXCEPTION IN DB WORKER", new Date);
|
|
6540
6622
|
console.error(err);
|