hfs 3.1.1 → 3.1.2
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/admin/assets/{index-BhGDgjyF.js → index-CpeyrW2d.js} +8 -8
- package/admin/assets/{index-yV2Zu9R8.js → index-DI_SOdzQ.js} +1 -1
- package/admin/assets/{sha512-ZY3LjLgT.js → sha512-QTaxzUvZ.js} +1 -1
- package/admin/index.html +1 -1
- package/frontend/assets/{index-legacy-CQixuY0w.js → index-legacy-BQCEUtxs.js} +2 -2
- package/frontend/assets/{index-legacy-3MaA1vS1.js → index-legacy-DLISyaZ1.js} +1 -1
- package/frontend/assets/{sha512-legacy-iPKPjhP1.js → sha512-legacy-CHdxh7x9.js} +1 -1
- package/frontend/index.html +1 -1
- package/npm-shrinkwrap.json +84 -75
- package/package.json +4 -4
- package/src/first.js +25 -17
- package/src/listen.js +2 -2
- package/src/nat.js +2 -2
- package/src/webdav.js +3 -0
package/src/first.js
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.quitting = void 0;
|
|
4
7
|
exports.onProcessExit = onProcessExit;
|
|
5
8
|
exports.onFirstEvent = onFirstEvent;
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const assert_1 = __importDefault(require("assert"));
|
|
6
11
|
const cbsOnExit = new Set();
|
|
7
|
-
function onProcessExit(cb) {
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
function onProcessExit(cb, order = 10) {
|
|
13
|
+
(0, assert_1.default)(Number.isInteger(order) && order >= 0, 'order must be an integer >= 0');
|
|
14
|
+
const rec = { cb, order };
|
|
15
|
+
cbsOnExit.add(rec);
|
|
16
|
+
return () => cbsOnExit.delete(rec);
|
|
10
17
|
}
|
|
11
18
|
exports.quitting = false;
|
|
12
19
|
// 'exit' event is handled as the last resort, but it's not compatible with async callbacks
|
|
13
|
-
onFirstEvent(process, ['exit', 'SIGQUIT', 'SIGTERM', 'SIGINT', 'SIGHUP'], signal => {
|
|
20
|
+
onFirstEvent(process, ['exit', 'SIGQUIT', 'SIGTERM', 'SIGINT', 'SIGHUP'], async (signal) => {
|
|
14
21
|
console.log('Quitting with signal:', signal || 'unknown');
|
|
15
22
|
exports.quitting = true;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const byOrder = lodash_1.default.groupBy(Array.from(cbsOnExit), 'order'); // this will be inherently ordered because keys are positive integers
|
|
24
|
+
for (const recs of Object.values(byOrder))
|
|
25
|
+
await Promise.allSettled(recs.map(({ cb }) => {
|
|
26
|
+
try {
|
|
27
|
+
return cb(signal);
|
|
28
|
+
}
|
|
29
|
+
// keep exit moving even when a synchronous cleanup fails after partially shutting down
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.error("Error while quitting", e);
|
|
32
|
+
return Promise.reject(e);
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
console.debug('Process exit');
|
|
36
|
+
process.exit(0);
|
|
29
37
|
});
|
|
30
38
|
// keep calling cb in a sync fashion – returning a promise instead would break the code for argv.updating (update.ts)
|
|
31
39
|
function onFirstEvent(emitter, events, cb) {
|
package/src/listen.js
CHANGED
|
@@ -70,8 +70,8 @@ const consoleLog_1 = require("./consoleLog");
|
|
|
70
70
|
const first_1 = require("./first");
|
|
71
71
|
let httpSrv;
|
|
72
72
|
let httpsSrv;
|
|
73
|
-
// update relaunch can keep a bridge process alive, so we proactively close listeners here to release ports before the next binary binds
|
|
74
|
-
(0, first_1.onProcessExit)(() => Promise.all([stopServer(httpSrv), stopServer(httpsSrv)]));
|
|
73
|
+
// the update relaunch can keep a bridge process alive, so we proactively close listeners here to release ports before the next binary binds; do it before (5) the storage file is closed, because sockets write there
|
|
74
|
+
(0, first_1.onProcessExit)(() => Promise.all([stopServer(httpSrv), stopServer(httpsSrv)]), 5);
|
|
75
75
|
const openBrowserAtStart = (0, config_1.defineConfig)('open_browser_at_start', true);
|
|
76
76
|
exports.baseUrl = (0, config_1.defineConfig)(misc_1.CFG.base_url, '', x => /(?<=\/\/)[^\/]+/.exec(x)?.[0]); // compiled is host only
|
|
77
77
|
async function getBaseUrlOrDefault() {
|
package/src/nat.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getNatInfo = exports.getPublicIps = exports.upnpClient = exports.defaultBaseUrl = void 0;
|
|
7
7
|
const valtio_1 = require("valtio");
|
|
8
|
-
const
|
|
8
|
+
const nat_upnp_1 = require("@rejetto/nat-upnp");
|
|
9
9
|
const debounceAsync_1 = require("./debounceAsync");
|
|
10
10
|
const cross_1 = require("./cross");
|
|
11
11
|
const github_1 = require("./github");
|
|
@@ -30,7 +30,7 @@ exports.defaultBaseUrl = (0, valtio_1.proxy)({
|
|
|
30
30
|
return `${this.proto}://${(0, cross_1.ipForUrl)(ip || 'localhost')}${!port || port === defPort ? '' : ':' + port}`;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
exports.upnpClient = new
|
|
33
|
+
exports.upnpClient = new nat_upnp_1.Client({ timeout: 4_000 });
|
|
34
34
|
const originalMethod = exports.upnpClient.getGateway;
|
|
35
35
|
// other client methods call getGateway too, so this will ensure they reuse this same result
|
|
36
36
|
exports.upnpClient.getGateway = (0, debounceAsync_1.debounceAsync)(() => originalMethod.apply(exports.upnpClient), { retain: cross_1.HOUR, retainFailure: 30_000 });
|
package/src/webdav.js
CHANGED
|
@@ -75,9 +75,12 @@ const webdav = async (ctx, next) => {
|
|
|
75
75
|
const ua = ctx.get('user-agent');
|
|
76
76
|
if (path.includes('/._') && ua?.startsWith('WebDAVFS')) { // too much spam from Finder for these files that can contain metas
|
|
77
77
|
ctx.state.dontLog = true;
|
|
78
|
+
ctx.state.webdavDetected = true;
|
|
78
79
|
return ctx.status = cross_1.HTTP_FORBIDDEN;
|
|
79
80
|
}
|
|
80
81
|
const isWebdavAuthRequest = WEBDAV_METHODS.has(ctx.method) || WEBDAV_HINT_HEADERS.some(h => ctx.get(h));
|
|
82
|
+
if (isWebdavAuthRequest)
|
|
83
|
+
ctx.state.webdavDetected = true;
|
|
81
84
|
if (isWebdavAuthRequest && ua && (0, auth_1.getCurrentUsername)(ctx))
|
|
82
85
|
webdavDetectedAgents.try(webdavAgentKey(ctx, ua), () => true);
|
|
83
86
|
if (ctx.method === 'OPTIONS') {
|