hfs 0.47.2 → 0.47.3
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 +1 -1
- package/src/const.js +1 -1
- package/src/listen.js +5 -3
- package/src/middlewares.js +8 -3
- package/src/util-os.js +1 -1
package/package.json
CHANGED
package/src/const.js
CHANGED
|
@@ -38,7 +38,7 @@ exports.DEV = process.env.DEV || exports.argv.dev ? 'DEV' : '';
|
|
|
38
38
|
exports.ORIGINAL_CWD = process.cwd();
|
|
39
39
|
exports.HFS_STARTED = new Date();
|
|
40
40
|
const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
|
|
41
|
-
exports.BUILD_TIMESTAMP = "2023-08-
|
|
41
|
+
exports.BUILD_TIMESTAMP = "2023-08-29T08:36:23.856Z";
|
|
42
42
|
const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
|
|
43
43
|
exports.VERSION = pkg.version;
|
|
44
44
|
exports.RUNNING_BETA = exports.VERSION.includes('-');
|
package/src/listen.js
CHANGED
|
@@ -134,6 +134,8 @@ exports.httpsPortCfg = (0, config_1.defineConfig)('https_port', -1);
|
|
|
134
134
|
exports.httpsPortCfg.sub(considerHttps);
|
|
135
135
|
function startServer(srv, { port, host }) {
|
|
136
136
|
return new Promise(async (resolve) => {
|
|
137
|
+
if (!srv)
|
|
138
|
+
return 0;
|
|
137
139
|
try {
|
|
138
140
|
if (port < 0 || !host && !await testIpV4()) // !host means ipV4+6, and if v4 port alone is busy we won't be notified of the failure, so we'll first test it on its own
|
|
139
141
|
return resolve(0);
|
|
@@ -152,12 +154,12 @@ function startServer(srv, { port, host }) {
|
|
|
152
154
|
});
|
|
153
155
|
async function testIpV4() {
|
|
154
156
|
const res = await listen('0.0.0.0');
|
|
155
|
-
await new Promise(res => srv.close(res));
|
|
157
|
+
await new Promise(res => srv === null || srv === void 0 ? void 0 : srv.close(res));
|
|
156
158
|
return res > 0;
|
|
157
159
|
}
|
|
158
160
|
function listen(host) {
|
|
159
161
|
return new Promise(async (resolve, reject) => {
|
|
160
|
-
srv.listen({ port, host }, () => {
|
|
162
|
+
srv === null || srv === void 0 ? void 0 : srv.listen({ port, host }, () => {
|
|
161
163
|
const ad = srv.address();
|
|
162
164
|
if (!ad)
|
|
163
165
|
return reject('no address');
|
|
@@ -203,7 +205,7 @@ async function getServerStatus() {
|
|
|
203
205
|
};
|
|
204
206
|
async function serverStatus(h, configuredPort) {
|
|
205
207
|
var _a;
|
|
206
|
-
const busy = await h.busy;
|
|
208
|
+
const busy = await (h === null || h === void 0 ? void 0 : h.busy);
|
|
207
209
|
await (0, misc_1.wait)(0); // simple trick to wait for also .error to be updated. If this trickery becomes necessary elsewhere, then we should make also error a Promise.
|
|
208
210
|
return {
|
|
209
211
|
...lodash_1.default.pick(h, ['listening', 'error']),
|
package/src/middlewares.js
CHANGED
|
@@ -107,15 +107,20 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
107
107
|
if (!node)
|
|
108
108
|
return sendErrorPage(ctx, const_1.HTTP_NOT_FOUND);
|
|
109
109
|
if (ctx.method === 'POST') { // curl -F upload=@file url/
|
|
110
|
+
if (ctx.request.type !== 'multipart/form-data')
|
|
111
|
+
return ctx.status = const_1.HTTP_BAD_REQUEST;
|
|
110
112
|
ctx.body = {};
|
|
111
113
|
const form = (0, formidable_1.default)({
|
|
112
114
|
maxFileSize: Infinity,
|
|
115
|
+
allowEmptyFiles: true,
|
|
113
116
|
//@ts-ignore wrong in the .d.ts file
|
|
114
117
|
fileWriteStreamHandler: f => (0, upload_1.uploadWriter)(node, f.originalFilename, ctx)
|
|
115
118
|
});
|
|
116
|
-
form.parse(ctx.req
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
return new Promise(res => form.parse(ctx.req, err => {
|
|
120
|
+
if (err)
|
|
121
|
+
console.error(String(err));
|
|
122
|
+
res();
|
|
123
|
+
}));
|
|
119
124
|
}
|
|
120
125
|
if (!await (0, vfs_1.nodeIsDirectory)(node))
|
|
121
126
|
return !node.source && await next()
|
package/src/util-os.js
CHANGED
|
@@ -16,7 +16,7 @@ function getFreeDiskSync(path) {
|
|
|
16
16
|
throw Error('miss');
|
|
17
17
|
return Number((_a = /FreeSpace=(\d+)/.exec(one)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
18
18
|
}
|
|
19
|
-
const out = (0, misc_1.try_)(() => (0, child_process_1.execSync)(`df -k ${path}`).toString(), err => {
|
|
19
|
+
const out = (0, misc_1.try_)(() => (0, child_process_1.execSync)(`df -k "${path}"`).toString(), err => {
|
|
20
20
|
throw err.status === 1 ? Error('miss')
|
|
21
21
|
: err.status === 127 ? Error('unsupported')
|
|
22
22
|
: err;
|